Armstrong number is a number whose sum of ‘digits to the power of the number of digits’ is equal to the original number. E.g 153, 370 etc

Armstrong number in Python

Steps to Check Armstrong Number in Python

  1. Input a number.
  2. Count the number of digits in the number i.e n.
  3. Calulate sum of digits with power of n.
  4. If sum is equal to the original number then the number is Armstrong else not.

Python Program to Check Whether a Number is Armstrong

Output

output of armstrong number in python

Python Program to Find Armstrong Number in an Interval

To find Armstrong number in an interval we will use above program with for loop. Only we need to create a separate function and place the above code in it and call the function with loop number as an argument.

Output

Armstrong Number in an Interval

That’s all we need to write in python in order to check Armstrong number. Any doubts then comment below.

Close Menu