Maximum digital sum of a googol

In order to solve this problem, I just created a brute force algorithm in Haskell:

    import List
    import Char

    result = maximum [g (a^b) | a <- [1..99], b <- [1..99]]
      where g = sum . map digitToInt . show

    main = print $ result

The execution is pretty fast:

real 0m0.059s user 0m0.055s sys 0m0.003s

Published: September 11 2010

blog comments powered by Disqus