Check whether the given number is an Armstrong number.

In this python basic program, we will check whether the given number is an Armstrong number or not.

Steps to solve the program
  1. Take a number as input through the user.
  2. See the given example to understand what is an Armstrong number.
  3. Create a variable and assign its value equal to 0.
  4. 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.
  5. Now divide the number by 10 using //.
  6. If the value of the variable is equal to the input number then it is an Armstrong number.
  7. 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
				
			

calculate the area of the cylinder.

calculate simple interest.

Leave a Comment