Solution to problem #2. Attempting to use memoization.