# Taking an interest

Working with ‘while’ loops made me think about an old problem that still requires a brute force solution even with all the advances in math and computer science. There are simple formulas for determining the interest generated by a certain amount of money over x years, but compounding is a much more complex problem. If interest is compounded every year, then the principal is changing in an exponential way and simple formulas no longer suffice because they do not take into account the necessary information. In order to find out the total balance 15 years in the future, for example, you need not only the initial balance and rate but what the balance was in each of the previous 14 years (since each year’s balance depends on the previous year’s balance plus the interest earned). While working with ‘while’ loops, I decided to apply them to a brute force problem like compound interest. The result is below:

### Future Balance Calculator

What was your balance at the end of 2012? \$

For what year do you want to know your end of year balance?

What is your interest rate? %

You will have a balance of \$ at the end of