I have been trying to find the sum of a series defined by Σ(1+r(i))^1:n
in R where i
and n
is in (1:N)
. Both i
and n
are of the same length. The solution needs to be two functions, where function 1
calculates the expression (1+r)^n
and the second function 2
recursively calls function 1
to calculate the summation. I am struggling to create a way to call function 1
within function 2
and having it calculate the values recursively.
Example:
Rates Tenor Printrest
1.20% 1 1.012
1.35% 2 1.02718225
1.90% 3 1.058089859
2.01% 4 1.082856706
1.80% 5 1.093298847
1.70% 6 1.106434521
Answer 6.379862183