summaryrefslogtreecommitdiff
path: root/day1/exercise/amicable.py
diff options
context:
space:
mode:
Diffstat (limited to 'day1/exercise/amicable.py')
-rw-r--r--day1/exercise/amicable.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/day1/exercise/amicable.py b/day1/exercise/amicable.py
new file mode 100644
index 0000000..0986e33
--- /dev/null
+++ b/day1/exercise/amicable.py
@@ -0,0 +1,18 @@
+import math
+
+def aliquot(n):
+ sum = 0
+ for i in range(1, int(math.sqrt(n))+1):
+ if n % i == 0:
+ sum += i + n/i
+ return sum
+
+amicable = []
+for n in range(10000, 100000):
+ m = aliquot(n)
+ if aliquot(m) == n:
+ amicable.append((m, n))
+
+print amicable
+
+# please please please profile this.