3 ms·
The even perfect numbers all have the formula 2^(p - 1)(2^p - 1) for some prime `p`. In code that's ((1 << p) - 1) << (p - 1) for `p` = 2, 3, 5, 7 a
by amptorn 7y ago
The even perfect numbers all have the formula
2^(p - 1)(2^p - 1)
for some prime `p`. In code that's
((1 << p) - 1) << (p - 1)
for `p` = 2, 3, 5, 7 and 13, which is why you're seeing that interesting pattern of bits.
(There are no odd perfect numbers in the range under consideration.)
- pmiller2 7y agoYou should also note that there are no known odd perfect numbers, period. Any that do exist must exceed 10^1500.