Answer to Question #257735 in Python for Pavani

Question #257735

write a program to find armstrong numbers in the given range A to B (including A and B). an N -digit number is armstrong number if the number is equal to the sum of the Nth power of its digits.


1
Expert's answer
2021-10-27T16:22:39-0400
a = int(input("A = "))
b = int(input("B = "))
nums = []
for n in range(a, b+1):
    if n == sum([int(i)**len(str(n)) for i in str(n)]):
        nums.append(n)
print(f"Armstrong numbers in the range {a} to {b}:")
print(*nums, sep=',')




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