# How many times can (a) dollars fit into (b) dollars if the original amount keeps increasing by (c)%?

I am trying to find a formula that allows to me calculate how many times a dollar amount can fit into a larger dollar amount, where the amount keeps increasing each time the full amount is reached.

For example, if the starting price is 1 dollar and I have 100 dollars, the first dollar takes me down to 99 dollars, but now the next amount has increased by 1% to 1.01 dollars, now my total is 97.99 dollars and now the 1.01 dollars increase by a further 1%, etc.

I hope my explaining is clear enough, if any further details are required, please let me know.

Any help would be much appreciated.

Thanks.

The following pseudocode demonstrates what I think you're doing - correct me if I'm wrong.

input remaining, start_subtract, interest
subtract = start_subtract
count = 1
while remaining > 0:
remaining -= subtract
subtract *= interest
count += 1
return count


Then your example has remaining = 100, start_subtract = 1, interest = 1.01, and a quick Python program determines the answer to be 69 steps. The above is just by way of a sanity-check on the answer I derive below.

Note that the amount we're taking out at time-step $n$ (where the first time-step is $n=1$ and we take out $1$ dollar in your example) is $a \times c^{n-1}$. So the amount taken out before-and-including time-step $n$ is $$a \times (1 + c + \dots + c^{n-1}) = a \times \frac{c^n-1}{c-1}$$

So you're asking for the largest $n$ such that $b > a \times \frac{c^n-1}{c-1}$; i.e. such that $$\log\left(\frac{(c-1)b}{a} + 1\right) / \log(c) > n$$

Since that thing on the left is just a number, this is easy to find. When $c=1.01, b=100, a=1$, the left-hand side is about $69.661$, so we get $n=69$.

• Thanks very much for your answer. Your pseudocode example is correct, that is what I am trying to do. However, I am trying to model this final equation you posted in Excel, but I am having some trouble (it just returns 0), does this look correct? =LN((((1.01-1)^100)/1)+1)/LN(1.01) – MitchellNZ Feb 18 '18 at 22:19
• @MitchellNZ You've raised one of the innermost brackets to the power 100, rather than simply multiplying. – Patrick Stevens Feb 18 '18 at 22:20
• Oh I see! Thank you very much, this is great! – MitchellNZ Feb 18 '18 at 22:25
• Sorry to be a pain, if I were to calculate this in this reverse direction (where the amount is now starting at 100 dollars and the first decrease amount would be the 2 dollars it ended at), would the function be similar if I now have the n amount to remove? – MitchellNZ Feb 19 '18 at 0:31