ZLA
AST

Problem 16 - Power Digit Sum

Project Euler
Post Image
February 3, 2024
Read Time: 1 min

Problem

This problem comes from Project Euler 16

Problem

215=32768 2^{15} = 32768 and the sum of its digits is 3+2+7+6+8=26 3+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))