Thursday, 14 May 2015

Python Program to check a number is Armstrong number or not


This a Python program to check whether a given number is armstrong or not .
Generally a number is said to be an armstrong number if the cubes of the digits is equal to its original number .





PROGRAM  :
num = int(input('Enter any number : '))
sum = 0
copy = num
while copy > 0:
    remainder=copy%10
    sum += remainder ** 3
    copy //= 10
if num == sum:
    print(num,"is an Armstrong number")
else:
    print(num,"is an not Armstrong number")


OUTPUT : 
Python - Armstrong or not

Python - Armstrong or not




Similar Programs :  
C Program to check a number is Armstrong number or not
Cpp Program to check a number is Armstrong number or not
Java Program to check a number is Armstrong number or not