Re: primepi(2^35)

Max Alekseyev <[email protected]> Thu, 8 Jan 2026 10:36:37 -0500
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <CAJkPp5NUwtZuoxz9HcGc6V-R0W53fYgzt8On=xP7tibbsTnTKg@mail.gmail.com>
Here is a simple script that provides an interface to the state-of-art
primecount tool available from
https://github.com/kimwalisch/primecount

inline(primecountbin = "~/projects/primepi/primecount ");
{ PrimePi(n) = if(n<default(primelimit), primepi(n),
extern(concat(primecountbin,Str(n))) ); }
{ NthPrime(n) = extern(concat([primecountbin,"-n ",Str(n)])); }

Regards,
Max



On Tue, Jan 6, 2026 at 12:58 PM Loïc Grenié <[email protected]> wrote:

> On Tue 6 Jan, 2026, at 18:28, Ruud H.G. van Tol wrote:
>
>>
>> ? default(primelimit)
>> % 2000000000
>>
>>
>> ? primepi(2^35)
>> cpu time = 18,133 ms, real time = 18,162 ms.
>> % 1480206279
>>
>> ? primepi(10^11)
>> cpu time = 4,744 ms, real time = 4,752 ms.
>> % 4118054813
>>
>>
>> Q: Why is the bigger value returned faster?
>>
>
>       Because there is a table of precomputed pairs primepi/prime. If you
> fall near one
>   of the precomputed values, the computation is faster.
>
>           Happy new year,
>
>                   Loïc
>
>
>
>>
>> ? prime(1480206279)
>> cpu time = 18,874 ms, real time = 18,937 ms.
>> % 34359738337
>>
>> ? prime(4118054813)
>> cpu time = 4,909 ms, real time = 4,917 ms.
>> % 99999999977
>>
>>
>>