forked from TheAlgorithms/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solution to the Problem 16 has been added.
- Loading branch information
Thejus-Paul
committed
Nov 19, 2017
1 parent
0f78cd6
commit c787a22
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters