Ormiston triples: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Like Phix, added a faster version using 'primesieve'.) |
m (→{{header|Wren}}: Minor changes to first version including using the correct 'cacheSize' parameter for my machine though performance unaffected.) |
||
Line 1,822: | Line 1,822: | ||
var limit = 1e10 |
var limit = 1e10 |
||
var primes = Int.segmentedSieve(limit, |
var primes = Int.segmentedSieve(limit, 128 * 1024) |
||
var orm25 = [] |
var orm25 = [] |
||
var j = |
var j = limit/10 |
||
var count = 0 |
var count = 0 |
||
var counts = [] |
var counts = [] |
||
Line 1,852: | Line 1,852: | ||
Fmt.tprint("$,10d ", orm25, 5) |
Fmt.tprint("$,10d ", orm25, 5) |
||
System.print() |
System.print() |
||
j = |
j = limit/10 |
||
for (i in 0...counts.count) { |
for (i in 0...counts.count) { |
||
Fmt.print("$,d Ormiston triples before $,d", counts[i], j) |
Fmt.print("$,d Ormiston triples before $,d", counts[i], j) |
||
Line 1,875: | Line 1,875: | ||
===Faster version=== |
===Faster version=== |
||
{{libheader|wren-psieve}} |
{{libheader|wren-psieve}} |
||
This uses our bindings to the C++ library |
This uses our bindings to the C++ library ''primesieve'' and, as we're now iterating through the primes rather than sieving for them, uses very little memory compared to the first version. |
||
It's also far quicker - 4.4 seconds to search up to 1 billion and 43.4 seconds to search up to 10 billion. |
It's also far quicker - 4.4 seconds to search up to 1 billion and 43.4 seconds to search up to 10 billion. |