%I #17 Nov 19 2023 21:16:36
%S 0,0,1,1,2,2,3,3,3,3,4,4,5,5,5,5,2,2,3,3,3,3,4,4,4,4,4,4,5,5,6,6,6,6,
%T 6,6,7,7,7,7,4,4,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,9,9,9,9,9,9,10,
%U 10,10,10,11,11,8,8,8,8,8,8,9,9,9,9,10,10,10,10,10
%N a(n) = Pi(8,3)(n) + Pi(8,5)(n) + Pi(8,7)(n) - 3*Pi(8,1)(n), where Pi(a,b)(x) denotes the number of primes in the arithmetic progression a*k + b less than or equal to x.
%C In general, assuming the strong form of the Riemann Hypothesis, if 0 < a, b < k are integers, gcd(a, k) = gcd(b, k) = 1, a is a quadratic residue and b is a quadratic nonresidue mod k, then Pi(k,b)(n) > Pi(k,a)(n) occurs more often than not. This phenomenon is called "Chebyshev's bias". (See Wikipedia link and especially the links in A007350.) [Edited by _Peter Munn_, Nov 19 2023]
%C Define the "Chebyshev's bias sequence mod k" to be sequence q(n), where q(n) = Sum_{b is a quadratic nonresidue mod k, gcd(b, k) = 1} Pi(k,b)(n) - (r-1)*(Sum_{a is a quadratic residue mod k, gcd(a, k) = 1} Pi(k,a)(n)), r is the number of solutions to x^2 == 1 (mod n), then this sequence is the "Chebyshev's bias sequence mod 8". Also the initial terms are nonnegative integers, a(n) is negative for some n ~ 10^28.127. See page 21 of the paper in Journal of Number Theory in the Links section below.
%H Jianing Song, <a href="/A329242/b329242.txt">Table of n, a(n) for n = 1..10000</a>
%H Bays, Carter & Ford, Kevin & Hudson, Richard & Rubinstein, Michael, <a href="https://linkinghub.elsevier.com/retrieve/pii/S0022314X00926015">Zeros of Dirichlet L-functions near the Real Axis and Chebyshev's Bias</a>. Journal of Number Theory, Vol. 87, Issue 1, Mar 2001, pp. 54-76.
%H Andrew Granville and Greg Martin, <a href="http://www.jstor.org/stable/27641834">Prime number races</a>, Amer. Math. Monthly, 113 (No. 1, 2006), 1-33.
%e Below 2000000, there are 37116 primes congruent to 1 mod 8, 37261 primes congruent to 3 mod 8, 37300 primes congruent to 5 mod 8 and 37255 primes congruent to 7 mod 8, so a(2000000) = 37261 + 37300 + 37255 - 3*37116 = 468.
%o (PARI) a(n) = my(k=0); for(p=1, n, if(isprime(p)&&p>2, if(p%8==1, k-=3, k++))); k
%Y Cf. A007350, A329243.
%Y "Chebyshev's bias sequence mod k": A112632 (k=3), A038698 (k=4), A321862 (k=5), A321864 (k=7), A321865 (k=11).
%K sign
%O 1,5
%A _Jianing Song_, Nov 08 2019