016 - sum a power of 2
What is the sum of the digits of the number 2^1000?
See Problem 16.
We reuse a lot of code from previous problems. We transform the power of 2 to a string and then a list of ints so as to get the digits. The quick sum operator is borrowed from Python Idioms.
num_str = map (int, str (2**1000)) from operator import add sum = reduce (add, num_str) print sum
The answer is 1366. Computation time is 0.000294s.
