#!/usr/bin/env python # coding: utf-8 # In[ ]: 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)