Python program to check whether a given n-digit number is Armstrong number or not




Python program to check whether a given n-digit number is Armstrong number or not

What is an Armstrong number?

A number of length n is said to be Armstrong if it follows the below condition.

abc = a^3 + b^3 + c^3

Program to check Armstrong number using Python

n = int(input("Enter a number"))
s = 0
temp = n
while temp > 0:
   rem = temp % 10
   s += rem ** len(str(n))
   temp //= 10
if n == s:
   print(n,"is an Armstrong number")
else:
   print(n,"is not an Armstrong number")

check output here