CalmoSoft primes: Difference between revisions

→‎{{header|Wren}}: Incorporates two optimizations (see Talk Page) - about 20% faster than before.
(→‎{{header|Wren}}: Incorporates two optimizations (see Talk Page) - about 20% faster than before.)
Line 1,014:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
This runs in about 4.3.5 seconds (cf. Julia 1.3 seconds) on my Core i7 machine. However, 2.6 seconds of that is needed to sieve for primes up to 50 million.
<syntaxhighlight lang="ecmascript">import "./math" for Int, Nums
import "./fmt"for Fmt
Line 1,031:
if (pc - i < longest) break
if (i > 0) sum = sum - primes[i-1]
var isEven = (i == 0)
var sum2 = sum
for (j in pc-1..i) {
var temp = j - i + 1
if (temp < longest) break
if (j < pc - 1) sum2 = sum2 - primes[j+1]
if (Int.isPrime(sum2temp % 2) == 0 != isEven) {continue
if (Int.isPrime2(sum2)) {
if (temp > longest) {
longest = temp
9,486

edits