Solve problem 45 using Haskell.