mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-28 07:21:07 +00:00
Problem 16 Added
Solution to the Problem 16 has been added.
This commit is contained in:
parent
0f78cd6a55
commit
c787a22d93
15
Project Euler/Problem 16/sol1.py
Normal file
15
Project Euler/Problem 16/sol1.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
power = int(input("Enter the power of 2: "))
|
||||||
|
num = 2**power
|
||||||
|
|
||||||
|
string_num = str(num)
|
||||||
|
|
||||||
|
list_num = list(string_num)
|
||||||
|
|
||||||
|
sum_of_num = 0
|
||||||
|
|
||||||
|
print("2 ^",power,"=",num)
|
||||||
|
|
||||||
|
for i in list_num:
|
||||||
|
sum_of_num += int(i)
|
||||||
|
|
||||||
|
print("Sum of the digits are:",sum_of_num)
|
|
@ -49,3 +49,6 @@ PROBLEMS:
|
||||||
Using the rule above and starting with 13, we generate the following sequence:
|
Using the rule above and starting with 13, we generate the following sequence:
|
||||||
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
|
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
|
||||||
Which starting number, under one million, produces the longest chain?
|
Which starting number, under one million, produces the longest chain?
|
||||||
|
|
||||||
|
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?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user