In this python basic program, we will check whether the given number is an Armstrong number or not.
Steps to solve the program
- Take a number as input through the user.
- See the given example to understand what is an Armstrong number.
- Create a variable and assign its value equal to 0.
- While the number is greater than 0 divide the number by 10 using % and add the remainder raised to 3 to the variable that we have created.
- Now divide the number by 10 using //.
- If the value of the variable is equal to the input number then it is an Armstrong number.
- Print the output
num = a = 153
rev = 0
while a>0:
rem = a%10
rev = rev +rem**3
a= a//10
if rev == num:
print("It is a armstrong number")
else:
print("It is not a armstrong number")
Output :
It is a palindrome number