Posted by: Sourav | December 11, 2013

Armstrong Number in Python 3.3


a=input(“Please enter the number”)

b=len(a)

a=int(a)

d=int(a)

c=1

sum=0

#print (b)

while c<b:  

   m=int(a/10)   

   n=int(a%10)   

    sum=sum+(n**3)  

      c+=1    

       a=m

sum=sum+(a**3)

if sum==d:   

  print(‘%d is armstrong’ %d)

else:   

  print(“not”)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: