Sorry for the poor title, I am sure there is a name for this problem (and an easy solution)
I have an account balance of \$1000. When I want to buy some EUR, I need to sell USD with a fee of 1%. That means, if I want to sell \$1000 I can only sell \$990 because of the 1% fee.
But when I then choose to sell \$990, the fee logically decreases from \$10 to \$9.90 thus leaving me with a rest of \$0.10 in my balance.
How can I calculate the amount of USD I need to sell, to have as close to \$0.00 account balance as possible?
Solve for $x$, the amount, in US dollars, that you need to sell: $$x + 0.01x = 1.01x = 1000$$
$$x = \dfrac{1000}{1.01} \approx \$990.099 \approx \$990.10$$