Skip to content

Instantly share code, notes, and snippets.

@iacutone
Last active July 8, 2019 15:36
Show Gist options
  • Select an option

  • Save iacutone/58860bed14647e6866abcd73f985eacc to your computer and use it in GitHub Desktop.

Select an option

Save iacutone/58860bed14647e6866abcd73f985eacc to your computer and use it in GitHub Desktop.
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