Skip to content

Commit 374abf3

Browse files
authored
Merge pull request kal179#84 from denz647/patch-1
armstrong_number.py
2 parents eeb1a82 + fe27fb3 commit 374abf3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Amstrong

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

0 commit comments

Comments
 (0)