Is it true that primes of the form $5 + 6k$ exceed primes of the form $7 + 6k$ as $k \rightarrow \infty$?

105 Views Asked by At

I ran a little computational experiment where I computed the number of primes of the form $5 + 6k \leq n$ and $7 + 6k \leq n$, and noticed that as $n$ grew in size, primes of the form $5 + 6k$ started to exceed those of the form $7 + 6k$. Is this true? Do primes of the form $7 + 6k$ cross back over at large values of $n$?

Some results:

n = 10^1 -> delta =     0
n = 10^2 -> delta =    +1
n = 10^3 -> delta =    +6
n = 10^4 -> delta =    +5
n = 10^5 -> delta =   +22
n = 10^6 -> delta =   +34
n = 10^7 -> delta =  +189
n = 10^8 -> delta =  +419
n = 10^9 -> delta = +2106

The program I used to compute the above:

/**
 * primes.c
 * build:   gcc -O3 primes.c
 * run:     ./a.out <N>
 */

#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

void prime_pi(long n)
{
    uint8_t* sieve = calloc((n + 1) / 2, sizeof(uint8_t));
    assert(sieve != NULL);

    for (long i = 3; i * i <= n; i += 2)
    {
        if (sieve[i / 2] == 0)
        {
            for (int j = i * i; j <= n; j += 2 * i)
            {
                sieve[j / 2] = 1;
            }
        }
    }

    long count_of_5_plus_6k = 0;
    long count_of_7_plus_6k = 0;

    for (long i = 5; i <= n; i += 6)
    {
        if (sieve[i / 2] == 0)
        {
            count_of_5_plus_6k++;
        }
    }

    for (long i = 7; i <= n; i += 6)
    {
        if (sieve[i / 2] == 0)
        {
            count_of_7_plus_6k++;
        }
    }

    printf("|5 + 6k| = %ld\n", count_of_5_plus_6k);
    printf("|7 + 6k| = %ld\n", count_of_7_plus_6k);

    printf("delta = %ld\n", count_of_5_plus_6k - count_of_7_plus_6k);

    free(sieve);
}

int main(int argc, char* argv[])
{
    if (argc != 2) return EXIT_FAILURE;

    long n = strtoll(argv[1], NULL, 10);
    prime_pi(n);

    return EXIT_SUCCESS;
}

Edit 0: Add results.

Edit 1: Fixed inaccuracies in numbers and add program used to compute results.

Edit 2: Change 6i in code to 6k.

2

There are 2 best solutions below

2
On BEST ANSWER

First, there's some terminology we should be careful about. It's not correct to write that "primes of the form $5+6k$ exceed primes of the form $7+6k$" because the cardinality of the set of primes $5+6k$ is equal to the cardinality of the set of primes $7+6k$—these are both countably infinite sets, per Dirichlet's theorem. Furthermore, a strengthening of Dirichlet's theorem states that for any coprime $a,b$, the set of primes congruent to $a$ modulo $b$ has natural density $\frac{1}{\phi(b)}$, so in an asymptotic sense primes $5 \ \text{mod} \ 6$ are roughly around as prevalent as primes $7 \ \text{mod} \ 6$.

Nevertheless, the result is only asymptotic, so it does not paint the whole picture. The question which I believe you want to ask is the following, and it is indeed an interesting one.

For any coprime $(a,b)$, we denote by $\mathcal{P}(a,b,x)$ the number of primes at most $x$ which are congruent to $a \ \text{mod} \ b$.

Now, let us fix $N$ and let $a_1, a_2, a_3, ...,a_{\phi(N)}$ be a reduced residue system modulo $N$. Then must it be the case that for any permutation $\pi \in S_{\phi(N)}$ that there are arbitrarily large $x$ such that $\mathcal{P}(a_{\pi(1)}, N, x) \leq \mathcal{P}(a_{\pi(2)}, N, x) \leq \mathcal{P}(a_{\pi(3)}, N, x) \leq ... \leq \mathcal{P}(a_{\pi(\phi(N))}, N, x)$?

This is called the Shanks–Renyi race problem and I believe it is still open. Some weaker results have been proven assuming the generalized Riemann hypothesis, and it's possible that these weaker results may be sufficient to solve your problem, although the literature is pretty overwhelming.

I will also add that computational results are basically irrelevant here, because the "switches" might occur at incredibly large $x$, beyond the range of hardware. See Skewes Number. [Edit: this last sentence here may be incorrect, as the other answer indicates that a computational solution has been found for your specific problem. Nonetheless, in general, you cannot always rely on computers for such problems].

0
On

Yes, according to Bays and Hudson, Math. Comp. 32:571, 1978,

the number of primes up to $n$ of the form $3k+1$ exceeds

the number of primes up to $n$ of the form $3k+2$

when $n= 608,981,813,029$.