Ruud H.G. van Tol on Fri, 02 Feb 2024 04:23:07 +0100


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

Re: primepi([from,until])



On 2024-02-01 21:14, Bill Allombert wrote:
On Thu, Feb 01, 2024 at 09:08:00PM +0100, Ruud H.G. van Tol wrote:
I'm adding

   a(n) = #primes( [ n^2/4, (n+1)^2/4 ] );

to https://oeis.org/A220492

and was wondering if primepi() should grow a primepi([x1, x2]) variant,
to return the number of primes p, x1 <= p <= x2.
just do primepi(floor(x2))- primepi(ceil(x1)-1) or something ?

a(n) = #primes( [ n^2/4, (n+1)^2/4 ] )

? a( prime(2^16) );
cpu time = 3 ms, real time = 3 ms.


a1(n) = primepi((n+1)^2/4) - primepi(n^2/4)

? a1( prime(2^16) );
cpu time = 1min, 12,013 ms, real time = 1min, 12,437 ms.


So for this case, the primepi-delta-version is much slower.

-- Ruud