CalmoSoft primes: Difference between revisions
Content added Content deleted
m (→{{header|FreeBASIC}}: corrected output, 8 ==> 89) |
|||
Line 875: | Line 875: | ||
function calmo_prime_sequence(N) |
function calmo_prime_sequence(N) |
||
pri = primes(N) |
pri = primes(N) |
||
for |
for w in lastindex(pri):-1:2 |
||
psum = sum(pri[1:w]) |
|||
for d in 0:lastindex(pri)-w |
|||
if d > 0 |
|||
⚫ | |||
psum -= pri[d] |
|||
psum += pri[w + d] |
|||
end |
|||
if isprime(psum) |
|||
⚫ | |||
⚫ | |||
") of primes less than $N totals ", sum(pri[begin+d:d+w])) |
|||
if w > 24 |
|||
println(string(pri[d+1:d+6])[begin:end-1], ", ... ", |
|||
⚫ | |||
else |
else |
||
println("The sequence is: ", pri[ |
println("The sequence is: ", pri[d+1:d+w], "\n") |
||
end |
end |
||
return |
return |
||
Line 892: | Line 897: | ||
end |
end |
||
⚫ | |||
calmo_prime_sequence(100) |
|||
⚫ | |||
</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 41530) of primes less than 500000 totals 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 |
Longest Calmo prime seq (length 3001117) of primes less than 50000000 totals 72618848632313 |