Question
To Find whether the number is an Armstrong number or not.
Sample TestCaseExpected Output
Enter a number : 153 153 is an Armstrong number
Answer
num=int(input("Enter a number :"))
Sum=0
temp=num
while temp>0:
dig=temp%10
Sum+=dig**3
temp//=10
if num==Sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")

No comments:
Post a Comment