Neighbour primes: Difference between revisions

Content added Content deleted
m (→‎J: simplify)
m (→‎{{header|Wren}}: Minor tidy)
Line 1,388: Line 1,388:
=={{header|Wren}}==
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-math}}
{{libheader|Wren-seq}}
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascript">import "/math" for Int
<syntaxhighlight lang="wren">import "./math" for Int
import "/seq" for Lst
import "./fmt" for Fmt
import "/fmt" for Fmt


var primes = Int.primeSieve(504)
var primes = Int.primeSieve(504)
Line 1,401: Line 1,399:
if (Int.isPrime(p)) nprimes.add(primes[i])
if (Int.isPrime(p)) nprimes.add(primes[i])
}
}
Fmt.tprint("$3d", nprimes, 10)
for (chunk in Lst.chunks(nprimes, 10)) Fmt.print("$3d", chunk)
System.print("\nFound %(nprimes.count) such primes.")</syntaxhighlight>
System.print("\nFound %(nprimes.count) such primes.")</syntaxhighlight>