Solve #10 in Haskell.