Problem
This problem comes from Project Euler 16
Problem
and the sum of its digits is
What is the sum of the digits of the number ?
Solution
The solution I went for was fairly simple.
- Calculate
- Turn that number into a string first, then an array of integers
- Sum the array of integers
Code
# Project Euler: Problem 16
# Power digit sum
num = 2**1000
num_list = [int(i) for i in str(num)]
print(sum(num_list))