Skip to content

Commit 86d0c87

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#379 from kk3600/patch-1
added new file of armstrong number
2 parents 6276b19 + 9da7c02 commit 86d0c87

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

kk.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://www.facebook.com/swati.mallik.180/posts/158104889312424
2+
# subscribed by swati
3+
num = int(input("Enter a number: "))
4+
5+
# initialize sum
6+
sum = 0
7+
8+
# find the sum of the cube of each digit
9+
temp = num
10+
while temp > 0:
11+
digit = temp % 10
12+
sum += digit ** 3
13+
temp //= 10
14+
15+
# display the result
16+
if num == sum:
17+
print(num,"is an Armstrong number")
18+
else:
19+
print(num,"is not an Armstrong number")

0 commit comments

Comments
 (0)