day1/exercise/amicable.py
author Santosh G. Vattam <vattam.santosh@gmail.com>
Thu, 11 Mar 2010 18:01:23 +0530
changeset 380 669b72283b55
parent 94 8c92864c184b
permissions -rw-r--r--
Updated after Day 2 at GRDCS

def aliquot(n):
    sum = 1
    i = 2

    while i * i  < n:
        if n % i == 0:
            sum += i + (n / i)
        i += 1
    return sum

amicable = []

n = 1000
while n < 10000:
    m = aliquot(n)
    if m > n and aliquot(m) == n:
        print m, n
    n += 1