day1/exercise/amicable.py
author Christopher Burns <chris.d.burns@gmail.com>
Tue, 29 Jun 2010 00:30:21 -0500
branchscipy2010
changeset 431 9126059d6b37
parent 380 669b72283b55
permissions -rw-r--r--
DOC: Add slide about __module__ attribute.

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