Problem 20 in Haskell