You could gain a little by only generating prime numbers for your candidates. Eratosthenes' sieve is not that hard to implement.
I will post another solution using primes. Thanks for the tip!
I posted the prime-based solution here. The actual perfect number calculation time is now negligible, and the code can be a one-liner. But it requires being fed Mersenne Exponents. Fortunately, very few/small Mersenne Exponents quickly turn into perfect numbers which are too large for traditional memory structures.
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.