Problem 16

The 16th problem of the project_euler site was fairly easy to solve. With a one-line function, I am able to calculate the sum of the digits of 2^x, for a given x as input:

    import Char

    sumF = sum . map digitToInt . show . (^) 2

Then, it was just a matter of calling the function with 1000 as input. The execution was really fast, so ghci presented (0.00 secs, 0 bytes).

Published: November 14 2009

blog comments powered by Disqus