Solve #45 in Haskell.