CalmoSoft primes: Difference between revisions

m
(Undo revision 340330 by Wherrera (talk))
Tag: Undo
Line 992:
 
 
def calmo_prime_sequence(N=100maxp):
""" find the largest prime seq in primes < Nmaxp that sums to a prime """
pri = list(primerange(Nmaxp))
for window_sizewin in range(len(pri)+-1, 1, -1): # window size
forpsum i= in range(lensum(pri[:win])-window_size):
for bot in range(-1, len(pri)-win): # the last bottom of window
if isprime(sum(pri[i:i+window_size])):
if bot >= print(0:
psum -= pri[bot]
f'Longest Calmo prime seq (length {window_size}) of primes less than {N} totals {sum(pri[i:i+window_size])}:')
ifpsum window_size+= >pri[win 24:+ bot]
if isprime(sum(pri[i:i+window_size])psum):
print('[', ', '.join(map(str, pri[i:i+6])), ', ... ', ', '.join(map(str, pri[i+window_size-6:i+window_size])), ']\n', sep='')
print('Longest Calmo prime seq (length', win,
') of primes less than', maxp, 'totals', sum(pri[bot+1:bot+win+1]))
if win > 24:
print('[', ', '.join(map(str, pri[ibot+1:ibot+67])), ', ... ', ', '.join(map(str, pri[i+window_size-6:i+window_size])), ']\n', sep='')
', '.join(map(str, pri[bot-5+win:bot+win+1])), ']\n', sep='')
else:
print('The sequence is:', pri[ibot+1:ibot+win+window_size1], '\n')
return
 
 
for pmax in [100, 500_000, 50_000_000]:
calmo_prime_sequence()
calmo_prime_sequence(50_000_000pmax)
</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:
f'Longest Calmo prime seq (length {window_size}41530 ) of primes less than {N}500000 totals {sum(pri[i:i+window_size])}:')9910236647
[2, 3, 5, 7, 11, 13, ... 499787, 499801, 499819, 499853, 499879, 499883]
 
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>
4,105

edits