-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem16.py
More file actions
31 lines (21 loc) · 726 Bytes
/
Problem16.py
File metadata and controls
31 lines (21 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Code by @AmirMotefaker
# projecteuler.net
# https://projecteuler.net/problem=16
# Power digit sum
# Problem 16
# 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?
import time
start_time = time.time() #Time at the start of program execution
def Power_digit_sum(): # Power digit sum
total = 2**1000
total = str(total)
answer = 0
for i in range(len(total)):
answer += int(total[i])
print("Power digit sum 2**1000 =",answer)
Power_digit_sum()
print("2**1000 =", 2**1000)
end_time = time.time() #Time at the end of execution
print ("Time of program execution:", (end_time - start_time)) # Time of program execution
### Answer: 1366