#Skip to menu

Non-abundant sums

First read the problem description.
import itertools, sympy

def aliquot_sum(n):
    return sympy.divisor_sigma(n) - n

abundants = {n for n in range(2, 28123 + 1) if aliquot_sum(n) > n}
sum_of_abundants = set(a + b for (a, b) in itertools.combinations_with_replacement(abundants, 2))
sum(set(range(1, 28123+1)) - sum_of_abundants)
4179871

Source code of the solution(s):