Published: February 2, 2024

Project Euler

Problem 16 - Power Digit Sum

Problem

This problem comes from Project Euler 16

Problem

215=327682^{15} = 32768 and the sum of its digits is 3+2+7+6+8=263+2+7+6+8=26

What is the sum of the digits of the number 210002^{1000} ?

Solution

The solution I went for was fairly simple.

  1. Calculate 210002^{1000}
  2. Turn that number into a string first, then an array of integers
  3. 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))