Calculate how much you earn on your investment for one year. Then take this amount to calculate the interest rate, rather than the initial investment amount. In other words, use the same interest rate, but different amounts. Start with the first year, then the second and so on.
Here is the general formula if interest is accrued on a yearly basis: P x (1 + r)t, where P – is your initial deposit, r – is the yearly interest rate and t – is the number of years.