Skip to content

Instantly share code, notes, and snippets.

View rmg007's full-sized avatar
💭
✧*。٩(ˊᗜˋ*)و✧*。

Ryan Gonzalez rmg007

💭
✧*。٩(ˊᗜˋ*)و✧*。
View GitHub Profile
@daiando
daiando / enumerable_reduce_sample01.rb
Created December 7, 2015 01:13
Consider and arithmetico-geometric sequence where the nth term of the sequence is denoted by t(n)=n**2+1,n>0. In this challenge, your task is to complete the sum method which takes an integer n and returns the sum to the n terms of the series.
def sum_terms(n)
(1..n).reduce(0){|sum, i| sum + i**2 + 1}
end