Factor-perfect numbers: Difference between revisions
→{{header|Python}}
m (formatting) |
|||
Line 241:
<syntaxhighlight lang=python>''' Rosetta Code task Factor-perfect_numbers '''
from functools import cache
from sympy import divisors
Line 257:
listing = [a + [48
print('48 sequences using first definition:')
for j, seq in enumerate(listing):
Line 270 ⟶ 271:
@cache
def erdos_factor_count(number):
''' 'Erdos method '''
▲ return len(more_multiples([1], divisors(number)[1:-1])) + 1
return sum(erdos_factor_count(number // d) for d in divisors(number)[1:-1]) + 1
print("\nOEIS A163272: ", end='')
for num in range(
if num == 0 or
print(num, end=', ')
</syntaxhighlight>{{out}}
Line 309 ⟶ 311:
[12, 2, 2] [16, 3] [24, 2] [48]
OEIS A163272: 0, 1, 48, 1280, 2496, 28672, 29808, 454656, 2342912,
</pre>
|