f<-function(X){ F[1]<-100000 for (i in 1:6){ F[i+1]<-F[i]*1.03^2-i*X } return(F[7]) } f(5000) f(6000) f(6128)