Range Armstrong
Problem Description
Write a program to find the armstrong numbers between the given range
Input 1:Lower Range
Input 2: Upper range
Output:
List of Armstrong numbers
Refer sample input and output for formatting specification.
CODING ARENA
lower=int(input())
upper=int(input())
for num in range(lower, upper + 1):
order = len(str(num))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** order
temp //= 10
if num == sum:
print(num)
Test Case 1
Input (stdin)100
2000
Expected Output
153
370
371
407
1634
Test Case 2
Input (stdin)100
1000
Expected Output
153
370
371
407
No comments:
Post a Comment