Javatpoint Logo
Javatpoint Logo

Python Armstrong Number

In the fields of number theory and programming, the idea of Armstrong numbers is an intriguing subject. A number that is equal to the sum of its own digits multiplied by the number of digits it contains is known as an Armstrong number.

For instance, we should take the number 153. It has 3 digits: 1, 5, and 3. 13 + 53 + 33 = 1 + 125 + 27 = 153 is obtained by raising each digit to the power of 3 (the number of digits). 153 is an Armstrong number because the original number is equal to the sum of its cubes.

To find Armstrong numbers inside a given span, we can emphasize through each number in the stretch and check if it fulfils the Armstrong number condition. This can be done with the help of a for loop and some mathematical operations in Python.

The user's lower and upper interval bounds are used as input by the program to get started. It then repeats through each number in the reach from the lower bound to the upper bound (comprehensive). Using a loop and some mathematical operations, it calculates the sum of the digits raised to the power of each number for each number. The Armstrong number is printed if the calculated sum is the same as the current number. This program permits you to effectively find and show Armstrong numbers inside a predefined interval, giving a viable illustration of number control and cycle in Python.

Here, we print the Armstrong numbers within a specific given interval.

See this example:

This example shows all Armstrong numbers between 100 and 500.


Python Program to Find Armstrong Number between an Interval

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA