Compute the value of a finite geometric series. You are given a (the starting value), r(the ratio), and n , the number of terms in the finite series. Compute a +a*r+.....+a*r^(n-1)
r=2
n=7
a=rep(r,n)^(0:(n-1))
total=0
for (i in 0:(n-1))
{
total =total+r^i
}
No comments:
Post a Comment