I've ended up here whilst looking for some help with a calculation, I genuinely can't work out what formulae would be required! As this is basically algebra, I felt this was the most appropriate sub-forum.

The premise for this is calculating employee's gross pay and employers national insurance contributions given that I have a defined amount of money, X, to cover both. Essentially I bill monthly for Y per day, expenses come off the top line and what's left is to cover both my salary and employers NI contributions from the business. Employers NI is not a straight percentage, it's 13.8% of employee's earnings over £589 per month (roughly).

The math/algebra looks as follows;

X = A + B

B = 0.138*(A-589) = X - A

A= (B/0.138)+589 = X - B

How can you work out A and B when you input X (i.e A and B are unknowns). I assume this would be perhaps some iterative process?

Any input appreciated. I can work these out by trial and error with online tax calculators, or by using a third party umbrella company website, but I want to be able to build my own spreadsheet that tells me everything I need to know based on inputting just the number of days I'm billing for.