aboutsummaryrefslogtreecommitdiff
path: root/challenge-171/walt-mankowski/python/ch-1.py
blob: 90da29528ae0727811fe969fc82c1f915b339a74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python

def odd_divisors(n):
    od = [i for i in range(1,n//2+1,2) if n % i == 0]
    return od

abundant = []
n = 1
while len(abundant) < 20:
    od = odd_divisors(n)
    if sum(od) > n:
        abundant.append(n)
        sum_str = ' + '.join([str(i) for i in od])
        print(f"{len(abundant):2d}: {sum_str} = {sum(od)} > {n}")
    n += 2
print(abundant)