day1/exercise/amicable.py
changeset 64 333092b68926
child 94 8c92864c184b
equal deleted inserted replaced
63:f5eac04a00fe 64:333092b68926
       
     1 import math
       
     2 
       
     3 def aliquot(n):
       
     4     sum = 0
       
     5     for i in range(1, int(math.sqrt(n))+1):
       
     6         if n % i == 0:
       
     7             sum += i + n/i
       
     8     return sum
       
     9 
       
    10 amicable = []
       
    11 for n in range(10000, 100000):
       
    12     m = aliquot(n)
       
    13     if aliquot(m) == n:
       
    14         amicable.append((m, n))
       
    15 
       
    16 print amicable
       
    17 
       
    18 # please please please profile this.