CalmoSoft primes: Difference between revisions

m
Line 325:
7 + 11 + 13 + 17 + 19 + 23 + 29 + 31 + 37 + 41 + 43 + 47 + 53 + 59 + 61 + 67 + 71 + 73 + 79 + 83 + 89 = 953 which is prime
</pre>
 
=={{header|Julia}}==
The strech goal currently asks for the sequence. It's not possible to show the < 50 million sequence in the page, but the totals can be shown.
<syntaxhighlight lang="julia">using Primes
 
function calmo_prime_sequence(N = 100, showsequence = true)
pri = primes(N)
for window_size in lastindex(pri):-1:2
for i in firstindex(pri):lastindex(pri)-window_size
if isprime(sum(pri[i:i+window_size]))
println("Longest Calmo prime seq (length ", window_size + 1,
") of primes less than 100 totals ", sum(pri[i:i+window_size]))
showsequence && println("The sequence is: ", pri[i:i+window_size])
return
end
end
end
end
 
calmo_prime_sequence()
calmo_prime_sequence(50_000_000, false)
<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 100 totals 72618848632313
</pre>
 
 
=={{header|Phix}}==
4,102

edits