Skip to content

Commit b72cdac

Browse files
authored
Merge pull request Rishi098#32 from Mownika25/patch-1
Create Check_armstrong.py
2 parents 73b5717 + bc4b088 commit b72cdac

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Check_armstrong.py

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)