Problem 1 in Haskell