day1/exercise/amicable.py
author amit@shrike.aero.iitb.ac.in
Mon, 10 May 2010 22:46:29 +0530
changeset 397 28915381ac32
parent 380 669b72283b55
permissions -rw-r--r--
Changes from BHU workshop . changed variable names in list intro . pendulum.pychanged to pendulum_plot.py . Also an extra space added on slide 33 session1 day1

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