Adding problem 30 in Haskell