7.4 Recursive For Loop
There are usually multiple ways of figuring out how to calculate certain items.
For example, consider a different function defined as:
<- function(i1, t1){
compound 1 + i1)^t1
( }
Editing the code from subsection 7.2, this loop looks like:
<- 0.05
i for (t in 1:6){
print(compound(i,t))
}
Instead of finding the results in this way, we could have calculated it as follows:
<- 0.05
i <- 1
y for (count in 1:6){
<- (1 + i)*y
y print(y)
}
The variable \(count\) in the loop is included as a counter, i.e. the loop iterating 6 times. Mathematically, you may want to show why this approach is equivalent to that previously.