(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Program to find whether the given number is armstrong or not - TecGlance

Header Ads

Program to find whether the given number is armstrong or not


Program to find whether the given number is armstrong  or not

a=input("Enter any number : ")
num=a
sum=0
while a>0:
    re=a%10
    sum+=re**3
    a=a/10
if sum==num:
        print"The given number is an armstrong number"
else:
        print"The given number is not an armstrong number"

 OUTPUT :

 Enter any number :  153
The given number is an armstrong number
  
Enter any number :  371
The given number is an armstrong number
  
Enter any number :  123
The given number is not an armstrong number

No comments

Powered by Blogger.