Problem 14 in Haskell, great use case for memoization