Hello,

I'm trying to write a loop which will take my formula, successively assign values from a defined sequence (in my example its a sequence of (1 to 7) and then sum the values of each iteration. My code below, will return the last iterated value but not the sum of all iterated values. Is the issue related to how I am calling my interation ie using the range function? Any advice/help is much appreciated! Thanks!

```
cpnA<-30
y<-0.025
n<-8
p<-1000
for(i in range(1, n-1)){
pv<-sum((cpnA/(1+y)^i)) + ((p+cpnA)/(1+y)^8)}
```