CalmoSoft primes: Difference between revisions
Content added Content deleted
m (→Stretch task: sp) |
m (→Stretch task) |
||
Line 688: | Line 688: | ||
def calmo_prime_sequence(N=100 |
def calmo_prime_sequence(N=100): |
||
""" find the largest prime seq in primes < N that sums to a prime """ |
""" find the largest prime seq in primes < N that sums to a prime """ |
||
pri = list(primerange(N)) |
pri = list(primerange(N)) |
||
Line 695: | Line 695: | ||
if isprime(sum(pri[i:i+window_size])): |
if isprime(sum(pri[i:i+window_size])): |
||
print( |
print( |
||
f'Longest Calmo prime seq (length {window_size}) of primes less than {N} totals {sum(pri[i:i+window_size])}') |
f'Longest Calmo prime seq (length {window_size}) of primes less than {N} totals {sum(pri[i:i+window_size])}:') |
||
if |
if window_size > 24: |
||
print( |
print('[', ', '.join(map(str, pri[i:i+6])), ', ... ', ', '.join(map(str, pri[i+window_size-6:i+window_size])), ']\n', sep='') |
||
else: |
|||
print(pri[i:i+window_size], '\n') |
|||
return |
return |
||
calmo_prime_sequence() |
calmo_prime_sequence() |
||
calmo_prime_sequence(50_000_000 |
calmo_prime_sequence(50_000_000) |
||
</syntaxhighlight>{{out}} |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
Longest Calmo prime seq (length 21) of primes less than 100 totals 953 |
Longest Calmo prime seq (length 21) of primes less than 100 totals 953: |
||
The sequence is: [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89] |
The sequence is: [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89] |
||
Longest Calmo prime seq (length 3001117) of primes less than 50000000 totals 72618848632313 |
Longest Calmo prime seq (length 3001117) of primes less than 50000000 totals 72618848632313: |
||
[7, 11, 13, 17, 19, 23, ... 49999699, 49999711, 49999739, 49999751, 49999753, 49999757] |
|||
</pre> |
</pre> |
||