Addition Methods in Ruby
In this guide you will learn how to build a method using loops and recursion.
Guide Tasks
- Read Tutorial
- Complete the Exercise
Summary
Build a method using a for loop, while loop and recursion that can sum numbers.
Exercise Description
"Define a method that can sum up numbers using a for loop, while loop and recursion.
Example Data
'total = Summer.for_sum([1, 4, 11, 42, 12, 21])' -> expect(total).to eq(91) 'total = Summer.while_sum([4, 11, 42, 12, 21])' -> expect(total).to eq(90) 'total = Summer.recursive_sum([900, 4, 11, 42, 12, 21])' -> expect(total).to eq(990)
Real World Usage
This exercise will help you use loops and recursion on various addition methods.