solved problem009 in Haskell