🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X
Questions




































Write a python program to check whether the given number is Armstrong or not.

Last Updated : 20 Nov 2026 Jan 22, Jul 23, Jan 23, Jan 24, Jul 24, Jul 26

Solution:

# Take input from the user
num = int(input("Enter a number: "))

# Store the original number in a temporary variable
temp = num
num_digits = len(str(num))
sum_of_powers = 0

# Extract digits and calculate the sum of powers
while temp > 0:
    digit = temp % 10
    sum_of_powers += digit ** num_digits
    temp //= 10

# Check and display the result
if num == sum_of_powers:
    print(f"{num} is an Armstrong number.")
else:
    print(f"{num} is not an Armstrong number.")
✔ Verified by Expert
Latest Updates