示例#1
0
def abundant(x):
    return sum(euler_util.proper_divisors(x)) > x
示例#2
0
# amicable numbers

# sums[a] == b
# sums[b] == a

import euler_util

sums = [0] + [sum(euler_util.proper_divisors(i)) for i in range(1,10000)]
    
amicable = set()
for a in range(1,10000):
    b = sums[a]
    if b == a:
        continue
    if b < 10000:
        if sums[b] == a:
            amicable.add(a)
            amicable.add(b)
    else:
        s = sum(euler_util.proper_divisors(b))
        if s == a:
            amicable.add(a)

print sum(amicable)