Last active
July 8, 2019 15:36
-
-
Save iacutone/58860bed14647e6866abcd73f985eacc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pry' | |
| class Test | |
| attr_reader :list | |
| def initialize | |
| @list = [] | |
| end | |
| def mult(n, m) | |
| if m.zero? | |
| puts "The answer is #{list.sum}" | |
| list.sum | |
| return | |
| end | |
| list << n | |
| mult(n, m - 1) | |
| end | |
| # + n (x n (subl m) | |
| def add(n, m) | |
| if n.zero? || m.zero? | |
| puts "The answer is #{list.size + n}" | |
| list.size + n | |
| return | |
| end | |
| list << n | |
| add(n, m - 1) | |
| end | |
| # add1 (+ n (subl m)))) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment