summaryrefslogtreecommitdiff
path: root/day1/exercise/amicable_debug.py
diff options
context:
space:
mode:
authorMadhusudan.C.S2009-10-08 18:59:47 +0530
committerMadhusudan.C.S2009-10-08 18:59:47 +0530
commit9ca9d7ca7b91848630b9ab4224323422b75b4833 (patch)
tree95544a2a9d87119b12090a95a6f92d082a23caaa /day1/exercise/amicable_debug.py
parent678a4787cd71924efa823ef8bf86607f84e48173 (diff)
downloadworkshops-9ca9d7ca7b91848630b9ab4224323422b75b4833.tar.gz
workshops-9ca9d7ca7b91848630b9ab4224323422b75b4833.tar.bz2
workshops-9ca9d7ca7b91848630b9ab4224323422b75b4833.zip
Added quiz tex file and all exercise problems Madhu worked out.
Diffstat (limited to 'day1/exercise/amicable_debug.py')
-rw-r--r--day1/exercise/amicable_debug.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/day1/exercise/amicable_debug.py b/day1/exercise/amicable_debug.py
new file mode 100644
index 0000000..9369219
--- /dev/null
+++ b/day1/exercise/amicable_debug.py
@@ -0,0 +1,18 @@
+import math
+
+def aliquot(n):
+ sum = 0
+ for i in range(1, 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.