codemaniacstudio

Write a Python program to check whether a number is Armstrong number or not.

Write a Python program to check whether a number is Armstrong number or not.

SOLUTION....

n = int(input("Enter the number :- "))
temp = n
sum = 0 
while temp > 0:
  rem = temp % 10
  sum = sum + (rem * rem * rem)
  temp = temp //10
if sum == n:
  print("The number is Armstrong")
else:
  print ("The number is not Armstrong")

OUTPUT

Exit mobile version