Welcome to Project Lovelace! We're still in early development so there are still tons of bugs to find and improvements to make. If you have any suggestions, complaints, or comments please let us know on Discourse, Discord, or GitHub!

# Compound interest

## You will learn about: the most powerful force in the world according to Einstein. [citation needed]

Compound interest is when interest on a loan or investment is added back to the loan or investment. So it's like interest on interest! Compounding leads to exponential growth so it makes your investments grow big over time but also makes it much harder to pay off predatory loans and credit card debt.

If you start with an amount of money $m$ and the compound interest is calculated once a year with interest rate $r$ (as a fraction between 0 and 1) then after $n$ years you end up with a new amount $M$ given by $$M = m (1 + r)^n$$

This plot shows the growth of $m = 1,000$ dollars compounded every year at 10% ($r = 0.1$) for $n = 25$ years.

Submit some code with a function compound_interest(m, r, n) that computes the final amount $M$ after starting with an amount $m$ compounded yearly at a rate $r$ for $n$ years.

Input: Starting amount $m$, rate $r$, and number of years $n$.

Output: Final amount $M$.

Example

Input: 1000, 0.07, 25 Output: 5427.43

 Difficulty compound_interest(m, r, n)

You must be logged in to view your submissions.

### Notes

• Charging compound interest on loans was and is still considered a kind of usury by many religions and societies. The Romans and the Christian Bible condemn charging interest on loans to poor people as it is seen as a form of exploitation. On the extreme end, Islam forbids the charging of any kind of interest as it sees borrowing and lending as social transactions aimed at benefiting others and thus should not be profitable.
• The number $e$ was actually discovered by Jacob Bernoulli in 1683 when investigating compound interest. Now of course called Euler's number because of Stigler's law.
• The Rule of 72 is a quick rule/approximation for figuring out how long it would take for the amount to double: it's $72/r$ where $r$ is the interest rate as a percentage.

Let us know what you think about this problem! Was it too hard? Difficult to understand? Also feel free to discuss the problem, ask questions, and post cool stuff on Discourse. You should be able see a discussion thread below. Would be nice if you don't post solutions in there but if you do then please organize and document your code well so others can learn from it.