Do a brute force version of problem 24 in Haskell.