Do problem 10 slowly in Haskell.