Python program to check Armstrong number

Python program to check Armstrong number

Python program to check Armstrong number
In this example, we will learn how to check whether a number is Armstrong or not. A positive number is called Armstrong if
Python program to check Armstrong number
Where n is the number of digits in the given number.
# Armstrong number in python using while loop
n = int(input( ‘ Enter any number to check Armstrong : ‘ ) )
sum = 0
temp = n
while temp > 0
    digit = temp % 10 
    sum += digit ** 3
    temp //= 10
if( n == sum):
    print( ‘ Number is Armstrong ‘ )
else:
    print( ‘ Number is not Armstrong ‘ )
Output

Enter any number to check Armstrong : 125
Number is not Armstrong 
Again run the program
Enter any number to check Armstrong : 153
Number is Armstrong 

 

Python Program to add two numbers
Python program to find Area of Square
Python program to find Area of Triangle
Python program to swap two variables
Python program to convert Celsius to Fahrenheit
Python program to generate Random Number
Python program to convert Miles to Kolometers
Python program to find Largest of 2 numbers
Python program to check if number is Odd or Even
Python program to check if number is Positive Negative or Zero
Python program to check Leap Year
Types of Loop in Python
Python program to check Prime Number
Python program to Calculate Sum of N Natural Numbers
Python program to find sum of All Even Number between 1 to 10
Python program to find sum of All Odd Number between 1 to 10
Python program to check Armstrong Number

If you like my post please share it with your friends by simply clicking the below social media button, and Don’t forget to comment so we will update ourselves.

Share in a Single Click

Leave a Reply

Your email address will not be published. Required fields are marked *