Write a Python Program to Find Armstrong Number in an Interval.

Write a Python Program to Find Armstrong Number in an Interval.

Program
def myfun():
    lower=int(input("Enter the lower limit of the interval: "))
    upper=int(input("Enter the upper limit of the interval: "))
    
    for num in range(lower,upper+1):
        order=len(str(num))
        temp_num=num
        sum=0

        while(temp_num>0):
            digit=temp_num % 10
            sum=sum + digit ** order
            temp_num=temp_num // 10

        if(num==sum):
            print(num)
        
if __name__=="__main__":
    myfun()


Output:

Enter the lower limit of the interval: 10
Enter the upper limit of the interval: 10000

153
370
371
407
1634
8208
9474



More Questions


71 . Write a Python Program to Check Armstrong Number?
72 . Write a Python Program to Find Armstrong Number in an Interval.
73 . Write a Python Program to Find the Sum of Natural Numbers.
74 . Write a Python Program to Find LCM.
75 . Write a Python Program to Find HCF.
76 . Write a Python Program to Convert Decimal to Binary, Octal and Hexadecimal.
77 . Write a Python Program To Find ASCII value of a character.
78 . Write a Python Program to Make a Simple Calculator with 4 basic mathematical operations.
79 . Write a Python Program to Display Fibonacci Sequence Using Recursion.
80 . Write a Python Program to Find Factorial of Number Using Recursion.
81 . Write a Python Program to calculate your Body Mass Index.



For latest job updates join Telegram Channel: https://t.me/sateeshm