login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A189025
Number of primes in the range (n - 2*sqrt(n), n].
7
0, 1, 2, 2, 3, 3, 4, 3, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 4, 3, 4, 4, 3, 3, 4, 4, 4, 4, 4, 3, 4, 4, 4, 3, 3, 3, 3, 3, 4, 4, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 5, 5, 5, 4, 4, 4, 5, 4, 4, 4, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4, 5, 4, 4, 4, 5, 5, 6, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 3, 4
OFFSET
1,3
COMMENTS
Note that the lower bound, n-2*sqrt(n), is excluded from the count and the upper range, n, is included. The only zero term appears to be a(1). See A189027 for special primes associated with this sequence. This sequence is related to Legendre's conjecture that there is a prime between consecutive squares.
MATHEMATICA
cnt = 0; lastLower = -3; Table[lower = Floor[n - 2*Sqrt[n]]; If[lastLower < lower && PrimeQ[lower], cnt--]; lastLower = lower; If[PrimeQ[n], cnt++]; cnt, {n, 100}]
Table[PrimePi[n]-PrimePi[n-2Sqrt[n]], {n, 130}] (* Harvey P. Dale, Feb 28 2023 *)
PROG
(PARI) a(n)=if(n<default(primelimit), primepi(n)-primepi(n-2*sqrtint(n)), sum(k=n-2*sqrtint(n)+1, n, isprime(k))) \\ Charles R Greathouse IV, May 11 2011
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
T. D. Noe, Apr 15 2011
STATUS
approved