mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-21 20:47:10 +08:00
increment 1
This commit is contained in:
15
project_euler/Problem 16/sol1.py
Normal file
15
project_euler/Problem 16/sol1.py
Normal file
@ -0,0 +1,15 @@
|
||||
power = int(raw_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)
|
Reference in New Issue
Block a user