Python Implementation of Problem 16

View source code here on GitHub!

Project Euler Problem 16

Another good one for code golf

Problem:

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?

python.src.p0016.main() int
 1"""
 2Project Euler Problem 16
 3
 4Another good one for code golf
 5
 6Problem:
 7
 82**15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
 9
10What is the sum of the digits of the number 2**1000?
11"""
12
13
14def main() -> int:
15    return sum(int(x) for x in repr(2**1000))

Tags: large-numbers, digit-sum, power