day1/exercise/amicable.py
author Nishanth Amuluru <nishanth@fossee.in>
Tue, 14 Dec 2010 23:15:36 +0530
branchscipyin2010
changeset 456 a27ccfc118fb
parent 380 669b72283b55
permissions -rw-r--r--
removed sslc1.txt from circulate since it is not required

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