Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 417 Bytes

recursion-practice.md

File metadata and controls

16 lines (12 loc) · 417 Bytes

Recursion Practice

Work through these questions with your partner.

Consider this recursive method:

def mystery(x, y)
  return x if x < y
  return y + mystery(x - y, y)
end
  1. Walk through the evaluation of the method call: mystery(37, 10)
  2. What is the final value of mystery(37, 10)?
  3. Including the initial invocation, how many times was mystery put on the stack in the previous question?