Loïc Grenié on Tue, 06 Jan 2026 18:42:51 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: primepi(2^35)


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