Earliest difference between prime gaps: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Added a faster version using 'primesieve'. Also corrected cacheSize parameter for first version.) |
(→Faster version: Now finds earliest difference above 10 billion.) |
||
Line 1,467: | Line 1,467: | ||
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. |
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 - 1.9 seconds when looking for the earliest difference above 100 million |
It's also far quicker - 1.9 seconds when looking for the earliest difference above 100 million, 17.1 seconds for the earliest difference above one billion and even 10 billion (165 seconds) is now viable. |
||
<syntaxhighlight lang="ecmascript">import "./psieve" for Primes |
<syntaxhighlight lang="ecmascript">import "./psieve" for Primes |
||
import "./math" for Int |
import "./math" for Int |
||
import "./fmt" for Fmt |
import "./fmt" for Fmt |
||
var limit = |
var limit = 1e10 |
||
var gapStarts = {} |
var gapStarts = {} |
||
var it = Primes.iter() |
var it = Primes.iter() |
||
Line 1,508: | Line 1,508: | ||
{{out}} |
{{out}} |
||
⚫ | |||
<pre> |
<pre> |
||
Earliest difference > 10,000,000,000 between adjacent prime gap starting primes: |
|||
⚫ | |||
Gap 332 starts at 5,893,180,121, gap 334 starts at 30,827,138,509, difference is 24,933,958,388. |
|||
</pre> |
</pre> |