Solve #7 in Haskell.