Compound Interest

Write a program to compute the value of an investment compounded over time.

The formula for compound interest is:

A = P (1 + r/n) ^ (nt)

where:

  • P is the principal amount,
  • r is the rate per period,
  • t is the number of years invested,
  • n is the number of times the interest is compounded per year,
  • A is the amount at the end of the investment.

The program is a simple translation from the formula to code.