Header Ads

Python Program to Check the Number is Armstrong or Not


In this Program We Learn Number is Armstrong or Not Armstrong in Python Program
Python, Armstrong , even, odd, prime, Program, Find, Factorial,Number, While, Loop, python program, find factorial,  Number is Armstrong , find factorial in python,  Factorial of a Number Using While Loop, Python Program to Check the Number is Armstrong or Not


What is Armstrong Number?
An Armstrong Number is a Number if the sum of its digits raised to the power of 3 is equal to the original number then we say this number is called Armstrong Number
371 = 33+73+13    = 27 + 343 + 1  = 371


Example: Code Program


num = int(input("Enter Number:"))
 n = num 
 sum = 0
while n!=0:     
        r = int(n%10)     
        sum = sum + (r*r*r)     
        n = int(n/10
 if sum == num:     
        print(num, "is an Armstrong Number"
 else:    
      print(num, "is Not an Armstrong Number")

Output

Python, Armstrong , even, odd, prime, Program, Find, Factorial,Number, While, Loop, python program, find factorial,  Number is Armstrong , find factorial in python,  Factorial of a Number Using While Loop, Python Program to Check the Number is Armstrong or Not
Python, Armstrong , even, odd, prime, Program, Find, Factorial,Number, While, Loop, python program, find factorial,  Number is Armstrong , find factorial in python,  Factorial of a Number Using While Loop, Python Program to Check the Number is Armstrong or Not

No comments

Powered by Blogger.