your code will only return the last value, as it involves an assignment to a single object pv. the last thing written into pv is the last calculation, any previous would be overwritten. Additionally range() will only set i to values of 1 and 7, if you want the integer values between also you could use seq_len(n-1)
can you please clarify if you are trying to sum independent results of your function, or whether you intend them to accumulate during an iteration ?
1:5
sum(1:5)
cumsum(1:5)
sum(cumsum(1:5))