Prob 0023 ‐ Non‐Abundant Sums - maccergit/Euler GitHub Wiki
Once again, we are talking about divisors of a number, and the sum of those divisors. To summarize, so far we have been counting the number of divisors in prob0012, and the sum of the divisors in prob0021. From prob0021, we also know of a fast way to compute the sum, and we have added it to our utility library.
We can then build a list of all abundant numbers, and then use that to find the sums of all possible pairs of these numbers. If we then take that set and subtract it from the set of all numbers in the range, we end up with a new set consisting of only the non-abundant sum numbers.
It turns out that generating the set of abundant numbers takes under 1 µsec - while the fastfactor version is a bit faster, it does not have much impact on the total time. Instead, most of the time is done generating the set of sums and then subtracting it from the range of numbers.
Python's built in support for sets and set comprehensions makes this easy to code :