Chapter 9 Question 1 recursion with memoization