Is the number of primes congruent to 1 mod 6 equal to the number of primes congruent to 5 mod 6?

(I know that there's an infinity of primes congruent to 5 mod 6, but I don't know if there is an infinity of primes congruent to 1 mod 6.)

But what I'd really like to know is whether or not the number of primes ≡1 mod 6 less than a given n can be said to be asymptotically equal to the number of primes ≡5 mod 6 less than that n. So the "total" number of primes ≡1 mod 6 would be equal to the number of primes ≡5 mod 6.

(I hope this is understandable. I'd also like to know how to phrase this inquiry in a more standard fashion, if someone would tell me how to fix it.)

• You might ask like this: let $\pi_1(n)$ be the number of primes of the form $6k+1$ that are less than $n$, and $\pi_5(n)$ similarly. Then you can ask whether $\pi_1(n)/\pi_5(n)$ approaches a limit as $n$ increases without bound, and if so, whether that limit is 1.
– MJD
Commented Aug 22, 2012 at 1:13
• That's precisely what I mean; thank you. Commented Aug 22, 2012 at 1:14
• (You didn't ask for this, but for an elementary proof that there are infinitely many primes congruent to $1 \bmod 6$, consider the possible primes dividing a number of the form $k^2 - k + 1$.) Commented Aug 22, 2012 at 1:28
• Got it, thanks. Great to know. Commented Aug 22, 2012 at 2:35

Yes, this is true. A more general statement follows from a suitably strong form of Dirichlet's theorem on arithmetic progressions, namely that asymptotically the proportion of primes which are congruent to $a \bmod n$ (for $\gcd(a, n) = 1$) is $\frac{1}{\varphi(n)}$.

In the particular case that $n = 6$ it is possible to give a more elementary proof of a weaker result. Define the Dirichlet L-function

$$L(s, \chi_6) = \sum_{n=1}^{\infty} \frac{\chi_6(n)}{n^s}$$

where $\chi_6$ is the unique nontrivial Dirichlet character $\bmod 6$. This takes the form $\chi_6(n) = 1$ if $n \equiv 1 \bmod 6$, $\chi_6(n) = -1$ if $n \equiv 5 \bmod 6$, and $\chi_6(n) = 0$ otherwise. The Euler product of this L-function is

$$L(s, \chi_6) = \prod_p \left( \frac{1}{1 - \chi_6(p) p^{-s}} \right) = \prod_{p \equiv 1 \bmod 6} \left( \frac{1}{1 - p^{-s}} \right) \prod_{p \equiv 5 \bmod 6} \left( \frac{1}{1 + p^{-s}} \right).$$

It is possible to explicitly evaluate $L(1, \chi_6)$ and in particular to show that it is not zero; in fact,

$$L(1, \chi_6) = \int_0^1 \frac{1 - x^5}{1 - x^6} \, dx$$

and this can be evaluated using partial fractions (but note that the integrand is always positive so this number is definitely positive). So we conclude that

$$-\log L(s, \chi_6) = \sum_{p \equiv 1 \bmod 6} \log (1 - p^{-s}) + \sum_{p \equiv 5 \bmod 6} \log (1 + p^{-s})$$

approaches a nonzero constant as $s \to 1$ (if summed in the appropriate order) even though the first and second terms separately approach $\mp \infty$. So the contributions coming from primes in each residue class cancel out asymptotically. This is not quite as strong as the desired statement, though; if you fill in all the details in what I've said you'll show that the Dirichlet density of the primes congruent to $\pm 1 \bmod 6$ are the same but this should still be true for the natural density and this requires a further argument (I am not sure how much further, though).

For more details see any book on analytic number theory, e.g. Apostol.

• Thanks so much for this highly detailed answer and explanatory links. Commented Aug 22, 2012 at 1:27

Look up "prime races" at http://www.dms.umontreal.ca/~andrew/PDF/PrimeRace.pdf.

Their conclusion: "It does seem that “typically” qn + a has fewer primes than qn + b if a is a square modulo q while b is not."

So, since 1 is a quadratic residue mod 6, while 5 is not, there will typically be more primes of the form 6n+5 than 6n+1 (though their ratio does tend to 1).

If we cross out from sequence of positive integers all numbers divisible by $$2$$ and all numbers divisible by $$3$$, then all remaining numbers will be in one of two forms:

$$S1(n)=6n−1=5,11,17,..$$ or $$S2(n)=6n+1=7,13,19,....n=1,2,3,...$$ So all prime numbers also will be in one of these two forms and ratio 0f number of primes in the sequence $$S1(n)$$ to number of primes in the sequence $$S2(n)$$ tends to be $$1$$. See link

I proposed "matrix sieve" algorithm for finding primes:

Positive integers which do not appear in both arrays $$A1(i,j)=6i^2+(6i−1)(j−1)$$ and $$A2(i,j)=6i^2+(6i+1)(j−1)$$

                        |  6   11    16     21   ...|
A1(i,j) =   | 24   35     46    57   ...|
| 54   71     88   105   ...|
| 96  119    142   165   ...|
|...  ...  ...   ...     ...|

|  6    13   20    27   ...|
A2(i,j) =   | 24    37   50    63   ...|
| 54    73   92   111   ...|
| 96   121  146   171   ...|
|...      ...       ...        ...   ...|


are indexes $$k$$ of primes in the sequence $$S1(k)=6k−1$$ .

Positive integers which do not appear in both arrays $$A3(i,j)=6i^2−2i+(6i−1)(j−1)$$ and $$A4(i,j)=6i^2+2i+(6i+1)(j−1)$$

                               | 4       9     14       19.. |
|20      31     42       53...|
|48      65     82       99...|
A3(i,j)= |88     111     134      157..|
|...   ...      ...     ...   |

| 8      15      22     29 ..|
|28      41      54
A4(i,j)= |60     79       98     117..|
|104    129     154    179...|
|...    ...     ...     ...  |


are indexes $$k$$ of primes in the sequence $$S2(k)=6k+1$$. As we can see the expressions for arrays A1-A4 differ in that way: columns 1 in arrays A1 and A2 are the same, but columns 1 in arrays A3 and A4 are different, so number of primes in the sequence $$S1(k)$$ will be slightly bigger than number of primes in the sequence $$S2(k)$$. But the ratio of number of primes in the sequence $$S1(k)$$ to number of primes in the sequence $$S2(k)$$ tends to be 1 for greater ranges. For example: ratio of number of primes in $$S1$$ to the number of primes in $$S2$$ for the range [5;190] ratio=21/19=1,105263; for the range [5;950] ratio=82/77=1,064935; for the range [5;4750] ratio=323/314=1,028662 .for the range [5;23750] ratio=1332/1307=1,019138;for the range [5;118750] ratio=5613/5579=1,006094; for the range [5;593750] ratio=24345/24284=1,002512 and so on...

• It does provide an answer to the question Commented Jul 4, 2019 at 10:46