problem10 in haskell