AndreiL
Welcome to AndreiL.
Enjoy your time.
Please log in.

Perfect number algorithm - Python

Go down

Perfect number algorithm - Python

Post by Lucaci Andrei on Mon Feb 13, 2012 5:39 am

 1
2
3
4
5
6
7
8
9
10
11
def two(): 
l = input("Range: ")
for n in range(0, l):
s = 0
for i in range(1, (n / 2) + 1):
if (n % i) == 0:
s = s + i
if s == n:
print n, "is a perfect number."
else:pass
two()

avatar
Lucaci Andrei
"Tata Lor"


Number of messages : 222
Points : 2266743
Reputation : 1007
Registration date : 2008-08-15
Age : 25
Location : Cluj-Napoca

View user profile http://www.andreil.wgz.ro

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum