0

As a side result of another research we are conducting, the following question arose.

Question. Is the relative frequency of primes the same in all the following congruence classes modulo $50$: $1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49$?
In particular, we are interested in a proof that, as the size of the sample grows, the ratio between primes congruent to $\pm 1$ or $\pm7$ modulo $25$ and the their total converges to $\frac{1}{5}$.

Marco Ripà
  • 1,292
  • 2
  • Yeah, my only doubt is related to that "approximately". This clearly answers to my question above, but I wonder if there can be some kind of significant difference involving the relative frequency of primes in those congruence classes modulo $50$ if we fix the ceiling of our sample at, say, $10^{14}$ or even $10^{18}$ (here a "significant" difference would be $0.5 %$ and beyond). Infinity is quite large, and I wonder if we could safely assume an "equal" distribution of primes between the $20$ considered congruence classes in the interval $(10^1, 10^{14})$. – Marco Ripà Apr 09 '25 at 16:58
  • 1
    FYI, a related issue to your comment above is about prime number races. – John Omielan Apr 09 '25 at 17:02
  • In that range, you can just compute the distribution exactly. – lulu Apr 09 '25 at 17:02
  • 1
    Similar question: https://math.stackexchange.com/questions/5045200/who-wants-to-be-a-millionaire-primes-between-1-and-1000 – Dan Apr 09 '25 at 17:02
  • 1
    A few days ago, during our research, I run a Python program scanning the range $(10^{14}, 10^{14}+10^{4})$ and I got a ratio of $\frac{304 - 254}{304} \approx 0.16447$, which really surprised me... and this is how the whole story begun. – Marco Ripà Apr 09 '25 at 17:15
  • 1
    @MarcoRipà 50 primes out of 304 being in a set that "should" have probability 1/5 wouldn't be that unusual. A binomial random variable with $n = 304, p = 0.2$ has probability about $0.067$ of being 50 or less. – Michael Lugo Apr 09 '25 at 18:16
  • Is something likewise known even for modulo $10$? – Mike Apr 09 '25 at 18:56

1 Answers1

1

I threw together a computer program to list all the prime numbers under a million (there are 78,498 of them) and count the frequency of each p % 50 value (excluding 2 and 5 which are unique special cases).

  • 1: 3934
  • 3: 3946
  • 7: 3893
  • 9: 3924
  • 11: 3918
  • 13: 3927
  • 17: 3913
  • 19: 3928
  • 21: 3923
  • 23: 3932
  • 27: 3936
  • 29: 3886
  • 31: 3906
  • 33: 3936
  • 37: 3957
  • 39: 3928
  • 41: 3936
  • 43: 3924
  • 47: 3922
  • 49: 3927

Note that this is very close to a uniform distribution, with the “winner” (37, with 3957 primes) having only 1.8% higher frequency than the last place (29, 3886).

The set of “primes congruent to $\pm1$ or $\pm7$ modulo 25” corresponds to $\{1, 7, 18, 24, 26, 32, 43, 49\}$ in the above list, which have a combined relative frequency of $\frac{15678}{78496} \approx 0.19973$.


We had a similar discussion recently in Who wants to be a Millionaire? Primes between 1 and 1000, which discussed the last digits of prime numbers.

In short, the larger the upper bound on your prime numbers is, the closer the distribution gets to uniformity. This is because of the form of Dirichlet's theorem that states:

Equivalently, the primes are evenly distributed (asymptotically) among the congruence classes modulo $d$ containing $a$'s coprime to $d$.

Though, for finite lists of primes, the distribution may not be exactly uniform, and determining the “winner” is complicated without actually counting the frequencies.

Dan
  • 18,262
  • 1
    I absolutely agree, thank you very much for sharing the simulation results. The funny thing here is that I invoked Dirichlet's theorem a few years ago to prove Theorem 3 of this paper [https://nntdm.net/papers/nntdm-27/NNTDM-27-4-043-061.pdf ]: I'm clearly getting too old for playing with primes. – Marco Ripà Apr 09 '25 at 17:27