day1/exercise/aliquot.py
changeset 354 5dc6c3673f9d
parent 94 8c92864c184b
child 380 669b72283b55
--- a/day1/exercise/aliquot.py	Sun Jan 10 23:09:00 2010 +0530
+++ b/day1/exercise/aliquot.py	Tue Jan 12 19:03:34 2010 +0530
@@ -1,18 +1,13 @@
-def is_perfect_square(n):
-    i = 1
-    while i * i < n:
-        i += 1
-    return i * i == n, i
 
 def aliquot(n):
     sum = 1
     i = 2
 
-    is_ps, root = is_perfect_square(n)
-    while i < root:
+    while i * i < n: 
         if n % i == 0:
             sum += i + (n / i)
         i += 1
+    if n % i == 0: sum += i
     return sum
 
 n = int(raw_input('Enter a number? '))