problem9 in haskell