Print the Armstrong numbers between two intervals | FACE Prep
Published on 10 Mar 2020
Program to print all the Armstrong numbers between the two intervals is discussed here. A number is said to be an Armstrong number when the sum of nth power of digit of the number is equal to the number itself.
Algorithm to print Armstrong numbers between two intervals
- Input the start and end values.
- Repeat from i = start_value to end_value.
- Repeat until (temp != 0)
- remainder = temp % 10
- result = result + pow(remainder,n)
- temp = temp/10
- if (result == number)
- Print the number
- Repeat steps from 2 to 8 until the end_value is encountered.
Program to print the Armstrong numbers between the two intervals
Enter start value and end value: 100 500
Armstrong numbers between 100 and 500 are:370 371 407
Time complexity: O(n)
If you have any feedback about this
article and want to improve this, please write to firstname.lastname@example.org