Program to check the Armstrong number

Armstrong number is also known as narcissistic number. A number is equal to the sum of the cubes of its own digits.

For Example:
372 is an Armstrong number since
372 = 333+777+111.

Program
n= int(input("Enter a number"))

sum = 0
temp = n
while temp>0:
digit = temp%10
sum+=digit*3
temp//=10
if n == sum:
print(n, "is an Armstrong number")
else:
print(n, "is not a Armstrong number"))

Leave a Reply