Python Program to Check the Number is Armstrong or Not
In this Program We Learn Number is Armstrong or Not Armstrong in Python Program
What is Armstrong Number?
An Armstrong Number is a Number if the sum of its digits
raised to the power of 3 is equal to the original number then we say this
number is called Armstrong Number
371 = 33+73+13 =
27 + 343 + 1 = 371
Example: Code Program
num = int(input("Enter Number:"))
n = num
sum = 0
while n!=0:
r = int(n%10)
sum = sum + (r*r*r)
n = int(n/10)
if sum == num:
print(num, "is an Armstrong Number")
else:
print(num, "is Not an Armstrong Number")
Output
Post a Comment