Haskell solution to Euler 14.