- Notifications
You must be signed in to change notification settings - Fork 46.7k
/
Copy pathsol2.py
30 lines (23 loc) · 567 Bytes
/
sol2.py
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
"""
Problem 16: https://projecteuler.net/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?
"""
defsolution(power: int=1000) ->int:
"""Returns the sum of the digits of the number 2^power.
>>> solution(1000)
1366
>>> solution(50)
76
>>> solution(20)
31
>>> solution(15)
26
"""
n=2**power
r=0
whilen:
r, n=r+n%10, n//10
returnr
if__name__=="__main__":
print(solution(int(str(input()).strip())))