Factor-perfect numbers: Difference between revisions

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] for a in sorted(more_multiples([1], divisors(48)[1:-1]))] + [[1, 48]]
return len for a in sorted(more_multiples([1], divisors(number48)[1:-1]))] + [[1, 48]]
print('48 sequences using first definition:')
for j, seq in enumerate(listing):
Line 270 ⟶ 271:
 
 
@cache
def count_multiple_sequences(number):
def erdos_factor_count(number):
''' Counts using the first definition, plus one extra for [1, n] '''
''' '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(500_0002_400_000):
if num == 0 or count_multiple_sequenceserdos_factor_count(num) == num:
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>
 
4,102

edits