Write a Python Program to Find Armstrong Number in an Interval

Python Program to Find Armstrong Number in an Interval

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Python Program to Find Armstrong Number in an Interval
Python Program to Find Armstrong Number in an Interval

Write a Python Program to Find Armstrong Number in an Interval

PROGRAM: Python Program to Find Armstrong Number in an Interval

/* Python Program to Find Armstrong Number in an Interval */

# Program to check Armstrong numbers in a certain interval

lower = 100
upper = 2000

for num in range(lower, upper + 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)

OUTPUT :-

153
370
371
407
1634

Leave a Reply

Your email address will not be published. Required fields are marked *