R study notes

Monday, October 20, 2014

Exercise-10

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
}
Posted by little6 at 8:26 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

little6
View my complete profile

Blog Archive

  • ►  2015 (2)
    • ►  November (1)
    • ►  February (1)
  • ▼  2014 (58)
    • ►  November (9)
    • ▼  October (29)
      • R语言系列:简单作图
      • R语言矩阵运算
      • R语言绘图 制图的一些要点
      • Exercise-11
      • Exercise-10
      • Exercise-9
      • Exercises-8
      • Random Code in Class 10/13/2014
      • Exercises-3
      • Exercises-2
      • Exercises-1
      • sets {base}
      • match
      • The %in% operator in R
      • R软件中排序:sort(),rank(),order()
      • R unname Function
      • R dim Function
      • “e” 科学记数:
      • Printing Fewer Digits (or More Digits)
      • Complex
      • statistical info
      • %%, %/% operators
      • cat
      • get
      • R书精选
      • Finding and removing duplicate records
      • Class assignment: fibonacci
      • Writing text and output from analyses to a file
      • R基本数据类型转换?
    • ►  September (20)
Simple theme. Powered by Blogger.