Wed Jul 21 2021
Armstrong Number
Python Programming1538 views
File Name: armstrong-number.py
#!/usr/bin/evn python
# Take input from the user
num = int(input("Enter a number: "))
sum = 0
temp = num
# While loop
while temp > 0:
digit = temp % 10
# Multiply 'digit' 3 times
sum += digit ** 3
# 'temp' divided 10
temp //= 10
# Display the result
if num == sum:
print num,"is an Armstrong number"
else:
print num,"is not an Armstrong number"
#***** Output *****
# Enter a number: 124
# 124 is not an Armstrong number
#or
# Enter a number: 153
# 153 is an Armstrong number
Reference:
Author:Geekboots