Skip to content

Commit a46ec79

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#268 from kousiksnai99/master
Create kousik.py
2 parents 661a883 + c98f56c commit a46ec79

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

kousik.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# https://www.facebook.com/kousik.snai.7/posts/995929887498735
2+
# subscribed by Code House
3+
# Python program to check if the number is an Armstrong number or not
4+
5+
# take input from the user
6+
num = int(input("Enter a number: "))
7+
8+
# initialize sum
9+
sum = 0
10+
11+
# find the sum of the cube of each digit
12+
temp = num
13+
while temp > 0:
14+
digit = temp % 10
15+
sum += digit ** 3
16+
temp //= 10
17+
18+
# display the result
19+
if num == sum:
20+
print(num,"is an Armstrong number")
21+
else:
22+
print(num,"is not an Armstrong number")

0 commit comments

Comments
 (0)