Power digit sum

The Project Euler website appears to have died, so I’m writing a post as a tribute to its memory. An old but fun problem goes like this:

2^15 = 32768, and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.

What is the sum of the digits of the number 2^1000?

The simplest way to approach this problem is to brute force it in a programming language with big integer support, e.g., Python:


while N>0:
    N, r = divmod(N,10)
    mysum += r

print mysum

RIP, Project Euler.