Posted by: Sourav | December 13, 2013

Perfect Number in Python


n=int(input(“Enter Number”))
sum=0
i=1
while(i<=n):

m=int(n%i)

if m==0:
sum=(sum+i)

i+=1

print (int(sum/2))
if (int(sum/2)==n):
print(“perfect”)
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: