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
|
122 Discussions
|
Please Login in order to post a comment
That’s a great breakdown of how reduce works, kind of like how an Acne Fighting Patch steadily works on a problem by building results over time through small, consistent actions.
can anyone having corrected code
This is the only solution that worked for me in 2025. Defeats the purpose of reduce enum tho.
Bignum=Integer Fixnum=Integer
def sum_terms(n) (1..n).reduce(0) {|sum,n| sum + n**2 +1} end