Armstrong numbers between two intervals
This Program name is Armstrong numbers between two intervals. Write a Python program to Armstrong numbers between two intervals, it has two test cases
The below link contains Armstrong numbers between two intervals question, explanation and test cases
https://drive.google.com/file/d/1nMwnGgwxLey1JhQEaQ_x-goS5_1DyVdL/view?usp=sharing
We need exact output when the code was run
A = int(input("enter value of A: "))
B = int(input("enter value of B: "))
for num in range(A, B + 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)
Comments
Leave a comment