Sandra Ross - 1 year ago 63

R Question

I would like to compute:

`$\sum_{j=1}^n r^j$ for $n=10, 20, 30, 40$, where $r=1.08$`

and to see the answers as a vector. I'm working with R; could anyone is able to explain to me how to do this?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

The value of r is unstated and I guessing that the formula being requested is not really the correct solution to a compound interest problem, but here is one answer to the question as currently posed:

```
r = 5.3; for (n in c(10,20,30,40) ) print( sum( r^(1:n) ) )
[1] 21555896
[1] 3.769856e+14
[1] 6.593006e+21
[1] 1.153034e+29
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**