prob14 in haskell