day1/exercise/aliquot.py
changeset 380 669b72283b55
parent 354 5dc6c3673f9d
--- a/day1/exercise/aliquot.py	Mon Mar 08 20:45:33 2010 +0530
+++ b/day1/exercise/aliquot.py	Thu Mar 11 18:01:23 2010 +0530
@@ -1,5 +1,7 @@
-
 def aliquot(n):
+    """returns the aliquot of a number which
+    is defined as the sum of all the proper
+    divisors of a number"""
     sum = 1
     i = 2
 
@@ -7,7 +9,7 @@
         if n % i == 0:
             sum += i + (n / i)
         i += 1
-    if n % i == 0: sum += i
+    if i*i == n: sum += i
     return sum
 
 n = int(raw_input('Enter a number? '))