Answer to Question #284504 in Python for Bannu

Question #284504

Armstrong numbers between two intervals



Write a program to print all the Armstrong numbers in the given



range A to B (including A and B). An N -digit number is an Armstrong number if the number equals the sum of the Nth power of its digits.


Inputs:


10


15


Output:


-1

1
Expert's answer
2022-01-04T01:10:20-0500
lwr = int(input('Enter lower bound here:'))



uppr = int(input('Enter upper bound here:'))







for numb in range(lwr, uppr + 1):







   # order of number



   odr = len(str(numb))



    



   # initialize sum



   sum = 0 tem = numb while tem > 0:



       digit = tem % 10



       sum += digit ** odr



       tem //= 10







   if numb == sum:



       print("The Armstrong numbers are: ",numb)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS