OFFSET
1,2
COMMENTS
For n>1, a(n)-a(n-1) is approximately pi(n)^2/n.
LINKS
A. Granville and G. Martin, Prime number races, arXiv:math/0408319 [math.NT], 2004.
Eric Weisstein's World of Mathematics, Prime Counting Function
EXAMPLE
m=0, n=1; pi(2) = (2-1)-(0) = 1 = number of nonprimes from 1 to 2, a(1) = 1 is a term. Now n=2, m=2.
pi(9) = (9-4)-(2-1) = 4 = number of nonprimes from 3 to 9, a(2) = 4 is a term. Now n=3, m=9.
pi(21) = (21-8)-(9-4) = 8 = number of nonprimes from 10 to 21, a(3) = 8 is a term.
MATHEMATICA
m=0; Do[If[PrimePi[n]==(n-PrimePi[n])-(m-PrimePi[m]), Print[PrimePi[n]]; m=n], {n, 1, 10^6, 1}]
PROG
(PARI) lista(nn) = my(m=0, list = List()); for (n=1, nn, my(k=2); while(primepi(k) != (k-primepi(k)) - (m-primepi(m)), k++); listput(list, primepi(k)); m = k; ); Vec(list); \\ Michel Marcus, Nov 13 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Manuel Valdivia, Oct 05 2007
EXTENSIONS
Edited by N. J. A. Sloane, Nov 05 2007
STATUS
approved