Non-abundant sums
First read the problem description.
import itertools, sympy
def aliquot_sum(n):
return sympy.divisor_sigma(n) - n
= {n for n in range(2, 28123 + 1) if aliquot_sum(n) > n}
abundants = set(a + b for (a, b) in itertools.combinations_with_replacement(abundants, 2))
sum_of_abundants sum(set(range(1, 28123+1)) - sum_of_abundants)
4179871
Source code of the solution(s):