You are viewing a single comment's thread. Return to all comments →
Bignum=Integer Fixnum=Integer
def sum_terms(n) (1..n).reduce(0) {|sum,n| sum + n**2 +1} end
Seems like cookies are disabled on this browser, please enable them to open this website
Ruby - Enumerable - reduce
You are viewing a single comment's thread. Return to all comments →
Bignum=Integer Fixnum=Integer
def sum_terms(n) (1..n).reduce(0) {|sum,n| sum + n**2 +1} end