def buildChain(seed): s = list() m = seed while not m in s: if m >= 1000000: return [] s.append(m) m = sum(all_factors(m)) - m s.append(m) return s
def c_n(n): return sum(all_factors(n))
from helpers import cached_prime, all_factors limit = 10**8 cached_prime(limit + 1) for i in range(2, limit + 1): list(all_factors(i))
def abundent(n): for i in range(n): s = sum(all_factors(i)) - i if i < s: yield i
from helpers import all_factors, cached_prime, factor from collections import defaultdict limit = 10000 visited = defaultdict(bool) cached_prime(limit * 10) numbers = [] for i in range(1, limit): if not visited[i]: s = sum(all_factors(i)) - i if i == sum(all_factors(s)) - s: if i != s: numbers.append(i) numbers.append(s) print (i, s) visited[i] = True visited[s] = True print sum(numbers)