summaryrefslogtreecommitdiff
path: root/day1/exercise/aliquot.py
diff options
context:
space:
mode:
Diffstat (limited to 'day1/exercise/aliquot.py')
-rw-r--r--day1/exercise/aliquot.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/day1/exercise/aliquot.py b/day1/exercise/aliquot.py
index 25518f0..7d5676c 100644
--- a/day1/exercise/aliquot.py
+++ b/day1/exercise/aliquot.py
@@ -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 @@ def aliquot(n):
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? '))