CalmoSoft primes: Difference between revisions

Undo revision 340330 by Wherrera (talk)
(Undo revision 340330 by Wherrera (talk))
Tag: Undo
Line 992:
 
 
def calmo_prime_sequence(maxpN=100):
""" find the largest prime seq in primes < maxpN that sums to a prime """
pri = list(primerange(maxpN))
for wwindow_size in range(len(pri)-+1, 1, -1):
psumfor =i sumin range(len(pri[:w])-window_size):
for d in range(-1, lenif isprime(sum(pri[i:i+window_size])-w):
if d >= 0: print(
f'Longest Calmo 'prime seq (length {window_size}) of primes less than', maxp,{N} 'totals', {sum(pri[d+1i:di+w+1window_size])}:')
psum -= pri[d]
psumif +=window_size pri[w> + d]24:
print('[', ', '.join(map(str, pri[i:i+6])), ', ... ', ', '.join(map(str, pri[i+window_size-6:i+window_size])), ']\n', sep='')
if isprime(psum):
print('Longest Calmo prime seq (length', w,
') of primes less than', maxp, 'totals', sum(pri[d+1:d+w+1]))
if w > 24:
print(''.join(list(str(pri[d+1:d+6]))[:-2]), ", ... ",
''.join(list(str(pri[d-5+w:d+w]))[1:]), "\n")
else:
print("The sequence is: ", pri[d+1i:d+wi+1window_size], "'\n"')
return
 
 
calmo_prime_sequence(pmax)
 
for pmax in [100, 500_000, calmo_prime_sequence(50_000_000]:)
calmo_prime_sequence(pmax)
</syntaxhighlight>{{out}}
<pre>
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]
Longest Calmo prime seq (length 3001117 ) of primes less than 50000000 totals 72618848632313:
 
[7, 11, 13, 17, 119, 23, ... 49999699, 49999711, 49999739, 49999751, 49999753], 49999757]
Longest Calmo prime seq (length 41530 ) of primes less than 500000 totals 9910236647
[2, 3, 5, 7, 1 , ... 499787, 499801, 499819, 499853, 499879]
 
Longest Calmo prime seq (length 3001117 ) of primes less than 50000000 totals 72618848632313
[7, 11, 13, 17, 1 , ... 49999699, 49999711, 49999739, 49999751, 49999753]
</pre>
 
4,102

edits