In the Python program, we will learn how to find Armstrong numbers between a specific range.
Here is the code of the program to find Armstrong numbers between a specific range.
# Python Program to Find Armstrong Number Between a Specific Range
# Take the Input From the User
lowerNum = int(input("Enter the Lower Number: "))
upperNum = int(input("Enter the Upper Number: "))
for num in range(lowerNum, upperNum + 1):
# order of number
order = len(str(num))
# initialize sum
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** order
temp //= 10
if num == sum:
print(num)
Enter the Lower Number: 5
Enter the Upper Number: 1000
5
6
7
8
9
153
370
371
407
Comments