We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Ruby - Enumerable - reduce
Ruby - Enumerable - reduce
Sort by
recency
|
119 Discussions
|
Please Login in order to post a comment
Bignum=Integer Fixnum=Integer
def sum_terms(n) (1..n).reduce(0) {|sum,n| sum + n**2 +1} end
what a terrible challenge. This is the most complicated way of doing
n**2 + 1
given that the input is n=25No matter what I try, including the posted solutions, I get some error related to Fixnum and Bignum. The proposed fix for this error doesn't work, either.