summaryrefslogtreecommitdiff
path: root/day1/exercise/amicable.py
blob: 6e5b2e1836bfe2f31948ab212b802e11b0e2199c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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