amt=50000 rate=.045 iter1=1:20 iter2=1:80 yearly=0 total=0 for(i in iter1) { yearly[i+1]<-yearly[i]+(yearly[i]+amt)*rate print(yearly[i]) print(yearly) } amt=50000 rate=.045 iter1=1:20 iter2=1:80 yearly=0 total=0 for(i in iter2) { qrtly[i+1]<-qrtly[i]+(qrtly[i]+amt)*rate/4 print(qrtly[i]) print(qrtly) } # while rate=.045 period=12 time=0 cap=5000 while(cap<=1000000) { time<-time+period; cap<-cap*(1+rate/period)+cap; print(cap) } print(c(time,"months")) print(c(time/period,"years"))