Skip to main content

Euler 0016

The Problem:

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

Considerations:

With python we can trivially calculate 2^1000 and then we can convert it to a string and sum its digits.

The Approach:

We calculate 2^1000 and then we can convert it to a string and sum its digits.


The Code:

power = 1000
number = 2**power

total_sum = 0
for digit in str(number):
    total_sum += int(digit)

print(total_sum)