This content was proof-read by Grammarly. You can Try Grammary for FREE
In this Python program, you’ll learn how to check if the given number is a Armstrong number or not and display it on the console.
How to Check if the Given Number is a Armstrong Number or Not in Python?
A number is said to be an Armstrong number of it is a positive number and if
abc… = an + bn + cn + …
In simple terms, an Armstrong number of 3 digits is the sum of cubes of each digit that is equal to the number itself.
num = 153 sum = 0 temp = num while temp > 0: digit = temp % 10 sum += digit ** 3 temp //= 10 if num == sum: print(num,"is an Armstrong number") else: print(num,"is not an Armstrong number")
153 is an Armstrong number
Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.