Armstrong Number - Coder's point

Saturday, June 1, 2019

Armstrong Number

 
num = int(input("Enter a Number: ")) sum = 0 temp = num while temp > 0: digit = temp % 10 sum += digit ** 3 temp //= 10 if num == sum: print(num,"is an Armstrong number") else: print(num,"is not an Armstrong number")

 OUTPUT :  
 Enter a Number: 51  
 51 is not an Armstrong number  
 Enter a Number: 371  
 371 is an armstrong number  

No comments:

Post a Comment