Solve #48 in Haskell.