Skip to content

Commit c8db262

Browse files
Create Check for Armstrong Number.py
1 parent 7b398a9 commit c8db262

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Check for Armstrong Number.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
num = int(input("Enter a number: "))
2+
length = len(str(num))
3+
t = num
4+
summation = 0
5+
while t > 0:
6+
digit = t % 10
7+
summation += digit ** length
8+
t //= 10
9+
if num != summation:
10+
print(num,"is not an Armstrong number")
11+
else:
12+
print(num,"is an Armstrong number")

0 commit comments

Comments
 (0)