Compound interest is the one computed for the sum of the principal amount (the money you invested) plus the interest acrued over the previous time period (most likely previous month) for calculating the interest.
Here is the algorithm to calculate the increasing capital
Let P be the principal amount you invest
Update (increase) the principal amount by adding the interest amount
Let the interval be month (for calculating the interest)
Let im be the montly interest (=annual interest rate / 12) in fraction (ie if annual interest rate is 12% then monthly interest rate is 12/12 = 1% = 0.01)
Calculate the interest for the first month
ia = P * im (im in fraction)
Update P
P = P + ia
Go back and Calculate the interest for the next month
or exit and be happy with the last value of P