def all_factor(num): factors = [1] sqrt = int(num ** 0.5) if sqrt ** 2 == num: factors.append(sqrt) sqrt -= 1 for x in range(2, sqrt + 1): if not (num % x): factors += [x, num // x] return factors def get_abundant(limit): gets = [12] for x in range(13, limit): if sum(all_factor(x)) > x: gets.append(x) return gets def get_none_dule_abundant(limit): factor = get_abundant(limit) flags = [1] * (limit + 1) for x in range(len(factor)): for y in range(x, len(factor)): s = factor[x] + factor[y] if s > limit: break flags[s] = 0 return [x[0] for x in enumerate(flags) if x[1]] print(sum(get_none_dule_abundant(28123)))