A Program to Check Armstrong Number
In this example, we are giving a program to check whether an n-digit integer is an Armstrong number or not. An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits.
Program to check Armstrong number:
# Check Armstrong numbernum = int(input('Enter a number: '))order = len(str(num))sum = 0temp = numwhile temp > 0:digit = temp % 10sum += digit ** ordertemp //= 10if num == sum:print(num,"is an Armstrong number")else :print(num,"is not an Armstrong number")
Output:
Enter a number: 153 153 is an Armstrong number Enter a number: 737 737 is not an Armstrong number