(a)
I guess there is a more pretty way to write this?
The algorithm below does what it says in the question. You put 500$ a month, next time you put money it has passed a month, the account change, so you update the account with the compounded interest before you add the 500.
the time(t)=1/12, and r=0.03
...repeat for all the months.
formula:
f(t) = Pe^tr
Continuously Compounded Interest Formula and Calculator
algorithm:
Code:
var months = 24;
var rate = 0.03;
var deposite = 500;
var account = 500;
i=1;
while(i<months)
{
account = account*(Math.pow(Math.E,((1/12)*rate)));
account +=deposite;
trace(account);
i++;
} Code:
1001.2515638028976
1503.7578242325983
2007.5219219548653
2512.5470054969496
3018.836231267267
3526.392763575127
4035.219774650508
4545.3204446638865
5056.69796174611
5569.355522008325
6083.296329561952
6598.523596538711
7115.040543110698
7632.85039751051
8151.956396051423
8672.361783147619
9194.069811334459
9717.083741288818
10241.40684184946
10767.042390037474
11293.993671076743
11822.263978414492
12351.85661374186