Add memoization to problem 26.