Today, We want to share with you armstrong number in python.In this post we will show you python program to print the first armstrong number in a given range, hear for Python Program to check whether the given number is Armstrong or not we will give you demo and example for implement.In this post, we will learn about Check Armstrong Number In GO Program with an example.
Python Program to Check Armstrong Number
153 = 1*1*1 + 5*5*5 + 3*3*3 // 153 is an Armstrong number.
Input: Give Any the number: 407 Output: Armstrong Number
Input: Give Any the number: 925 Output: Not an Armstrong Number
num = int(input("Give Any a number: ")) sum = 0 unknow = num while unknow > 0: digit = unknow % 10 sum += digit ** 3 unknow //= 10 if num == sum: print(num,"is an Armstrong number") else: print(num,"is not an Armstrong number")
Python program to print Armstrong numbers within the given range in Python
Input: Give Any lower range: 100 Give Any upper range: 500 Output: 153 370 371 407
#program to print Armstrong numbers within the given range in Python lower = int(input("Give Any lower range: ")) upper = int(input("Give Any upper range: ")) for num in range(lower, upper + 1): order = len(str(num)) sum = 0 #find the sum of the cube of each digit unknow = num while unknow > 0: digit = unknow % 10 sum += digit ** order unknow //= 10 if num == sum: print(num, end = ' ')
I hope you get an idea about python program to find armstrong number in an interval.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.