Python Program to check whether a given number is an Armstrong Number or not

Program

num = int(input("Enter the number:\t"))
temp = int(num)
Sum = 0
while temp != 0:
	digit  = temp % 10
	Sum  += digit ** 3
	temp = temp // 10
if num == Sum:
	print(num, "is an armstrong Number")
else:
	print(num, "is not an armstrong Number")

Output 1

Enter the number:	65
65 is not an armstrong Number

Output 2

Enter the number:	153
153 is an armstrong Number

Tags: