|
|
A071986
|
|
Parity of the prime-counting function pi(n).
|
|
7
|
|
|
0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
a(n) + a(n-1) = 1 if and only if n is prime. - Benoit Cloitre, Jun 20 2002
|
|
LINKS
|
|
|
FORMULA
|
a(n) = pi(n) mod 2.
|
|
EXAMPLE
|
a(6)=1 since three primes [2,3,5] are <= 6 and three is odd.
|
|
MATHEMATICA
|
Table[Mod[PrimePi[w], 2], {w, 1, 256}]
|
|
PROG
|
(PARI) a(n)=primepi(n)%2
(PARI) sq(n)=if (n<6, return(max(n-1, 0))); my(s, t); forsquarefree(i=1, sqrtint(n), t=n\i[1]^2; s+=moebius(i)*sum(i=1, sqrtint(t), t\i)); s;
a(n)=my(s); forsquarefree(i=1, logint(n, 2), s+=moebius(i)*sq(sqrtnint(n, i[1]))); s%2 \\ Charles R Greathouse IV, Jan 09 2018
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|