Non-Abundant Sums¶
Just like in problem 21, we'll define an aliquot_sum function and use that to find all the abundant numbers below 28,124 (as in problem 21, we could instead use a sieve to compute the divisor sums).
In [1]:
aliquot_sum = lambda n: sigma(n) - n
abundant_numbers = {k for k in range(1, 28124) if aliquot_sum(k) > k}
Then we check every integer less than 28,124 to see if it's the sum of any two abundant numbers, and if it is, remove it from a set containing all those integers. Whatever's left in that set are the non-abundant sums.
In [2]:
non_abundant_sums = set(range(1, 28124))
for n in range(1, 28124):
for m in abundant_numbers:
if n - m in abundant_numbers:
non_abundant_sums.discard(n)
break
sum(non_abundant_sums)
Out[2]:
4179871
Relevant sequences¶
Copyright (C) 2025 filifa¶
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license and the BSD Zero Clause license.