Javatpoint Logo
Javatpoint Logo

How to Find Armstrong Numbers between two given Integers

An integer is referred to as the Armstrong numbers of the order n. When it's each digit is separated, cubed, and added together then it will result in a sum that is the same as the number, (i.e., pqrs... = pn + qn + rn + sn +...).

If there is an Armstrong number with three digits, the total of cubes in each number is equal to the number in itself.

Example:

In this tutorial, we will learn how we can find Armstrong numbers between two given integers by using Python language.

For example:

The method we use below is easy. We look through all numbers within the range. For each number, we first determine the number of digits within it. Make the total number of decimal digits of the current number be the number "n". Then we calculate the sum of the" n-th" power of each digit. If the sum is greater than "K", then we record the result.

Code:

Output:

Please enter the lower range of the integer:  1000
Please enter the upper range of the integer:  10000
The Armstrong Numbers Between Two Given Integers:
1634
8208
9474

Conclusion

In this tutorial, we have discussed how to print Armstrong numbers between two given integers using Python programming.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA