5

I played the quiz game mentioned in the title (in an app) and got to the last question:

In what number do the most primes between $1$ and $1000$ end?

  • 1
  • 3
  • 7
  • 9

Up to $100$ we have $7$ primes ending in $3$, $6$ ending in $7$ and $5$ in $1$ and $5$ in $9$. I guess you can figure that out in the short time of a quiz show. Nevertheless, the correct answer is $7$ and that was my gut feeling so I picked it.

I am now, virtually, a millionare, but not a bit smarter about the matter. Is there any heuristic calculation, reasoning or idea to help one get to $7$ in a short amount of time?

I thought about factorizations. Because you need multiples of $3$ for a number ending in $7$, but for $1$ you need the $7$ so its also not a lot of ways. Any ideas?

Sokoban
  • 225
  • 9
  • 13
    No there is not. This is a stupid guessing question. There is no way to achieve that result throught logic besides just writing all primes and simply counting. Besides that it is probably the "easiest" question to ask as there is nothing to it. It is just a question of time. Maybe Gauss would have known the answer as he calculated a lot with primes and happens to know it. I am pretty sure that Terence Tao, who is known for his work on primes also would have to guess. – MathUnicorn Mar 13 '25 at 10:44
  • 5
    To get a feeling for it, the last digit 1,3,7,9 accours among the first 500.000 numbers respectively 10386,10382, 10403, 10365 times. As you see this is "evenly" distributed. So if you do not count the digits, the game master could also ask "which side on this four sides dice will I role?" – MathUnicorn Mar 13 '25 at 10:50
  • 5
    Dirichlet's Theorem states that the last digits of primes in any base are evenly distributed among the digits coprime to that base. See here: https://en.wikipedia.org/wiki/Dirichlet%27s_theorem_on_arithmetic_progressions – Mathemagician314 Mar 13 '25 at 11:29
  • 1
    the non-squares (relatively prime residues) modulo $m$ (square-free say for simplicity) tend to win prime races most of the time for reasons related to the shape of the respective Dirichlet $L$ functions; in particular modulo $10$ clearly of the $4$ relatively prime residues, $3,7$ are the non squares – Conrad Mar 13 '25 at 15:53
  • 1
    Yet another reference on the subject: https://en.wikipedia.org/wiki/Chebyshev%27s_bias – Levent Mar 13 '25 at 17:40
  • If I had to guess. I'd figure the as they are likely to be evenly distributed as we go along That the or $n$ of each in $100$ to $1000$ so there are $n+7$ threes, $n+6$ sevens and $n+5$ ones and nines. So I'd guess three and be wrong. I might do something about comparing the less prime less than $100$ and the last prime less than $1000$ but.... phoeey. – fleablood Mar 13 '25 at 19:08
  • It seems the fact that for n ending in 1, 3, 7 or 9, the number n^2 ends in 1 or 9 but not in 3 or 7, creates a tiny bias so numbers ending in 3 or 7 are a tiny bit more likely to be primes. Enough that the highest number of last digits is 3 or 7 at least for many numbers. Whether n is prime is also kind of random, which might create enough variability that very rarely 1 or 9 is the most common last digit. So you would be advised to guess that the answer is 3 or 7 for an almost 50% chance to win. Unless you memorise the table from Roland's answer. – gnasher729 Mar 14 '25 at 00:07

3 Answers3

10

Guessing 3 or 7 is more likely to be correct than guessing 1 or 9.

This is related to a topic in “comparative prime number theory” called “prime number races”. Andrew Granville and I have written an accessible introduction to this topic.

Greg Martin
  • 92,241
4

I happen to have a pretty large list of primes and did some counting:

                                            1         3         7         9
            0 < p <             10:         0         1         1         0
           10 < p <            100:         5         6         5         5
          100 < p <          1,000:        35        35        40        33
        1,000 < p <         10,000:       266       268       262       265
       10,000 < p <        100,000:      2081      2092      2103      2087
      100,000 < p <      1,000,000:     17230     17263     17210     17203
    1,000,000 < p <     10,000,000:    146487    146565    146590    146439
   10,000,000 < p <    100,000,000:   1274194   1274244   1274284   1274154
  100,000,000 < p <  1,000,000,000:  11271088  11272025  11271819  11271147
1,000,000,000 < p < 10,000,000,000: 101050133 101053126 101051725 101049993

As MathUnicorn pointed out, there's no real "winner"

To answer Levent's comment, if I count the ending digits of primes for all primes between 0 and 1,000,000, then between 1,000,000 and 2,000,000, continuing up to 100,000,000, I yield the following winners:

1 : 21  
3 : 23  
7 : 28  
9 : 28

In those 100 ranges the 1 was over-represented in 21 of them, 3 in 23, and so on. And if I change the size from 1 million to 10 million, the picture looks a bit different:

1 : 21  
3 : 27  
7 : 21  
9 : 31

Hence the explanation is (in my humble opinion): 3 and 7 were lucky.

Ronald
  • 904
  • 2
    Well, the winner is always $3$ or $7$. I wonder if there is an explanation for that. – Levent Mar 13 '25 at 12:03
  • A related March 2016 post, "Mathematicians shocked to find pattern in "random" prime numbers", with title from the New Scientist article, but this time focusing on consecutive primes like $13$ and $17$. – Tito Piezas III Mar 13 '25 at 15:42
  • @Levent people (e.g. Andrew Granville) have studied "prime races" and tried to explain this - I don't know what the state of the art is there but at least that's a word to look for. – Michael Lugo Mar 13 '25 at 15:45
  • 1
    I checked this sequence a bit further, for (10,000,000,000; 100,000,000,000) we have the first case when 1 wins. But in general narrow lead of 3/7 holds: 100000000000 915755611 915743823 915754298 915748570
    1000000000000 8372443850 8372470456 8372478663 8372464236
    10000000000000 77114409020 77114448042 77114370790 77114396969
    – alex st Mar 13 '25 at 18:15
1

Since I happen to be sitting in front of a computer, I can take the brute-force approach of just finding all the primes under 1000 (there are 168 of them) and counting the frequency of the last digits.

  • 1: 40
  • 2: 1
  • 3: 42
  • 5: 1
  • 7: 46
  • 9: 38

So, the answer is indeed 7. But is there a way to find that without actually listing all the primes?

Obviously, 2 and 5 are unique special cases, and aren't even answer choices, so we can ignore them. So, let's look at the base-ten multiplication table for how many ways there are to obtain composite numbers ending in those digits.

  • 1: 4 ways (1×1, 3×7, 7×3, 9×9)
  • 3: 4 ways (1×3, 3×1, 7×9, 9×7)
  • 7: 4 ways (1×7, 3×9, 7×1, 9×3)
  • 9: 4 ways (1×9, 3×3, 7×7, 9×1)

So, a four-way tie. Not helpful. I guess that's the reason for the form of Dirichlet's theorem saying “Equivalently, the primes are evenly distributed (asymptotically) among the congruence classes modulo d [i.e., the last digit in base d] containing a's coprime to d.”

But that's a long-run trend. Obviously it doesn't apply to the finite set of primes under 1000, because there is a clear winner of 7. Let's try other finite sets of primes, similar to @Roland's answer.

Domain 1 3 7 9 Mode Disuniformity
$p < 10$ 0 1 1 0 tie: 3, 7 $0.25$
$p < 100$ 5 7 6 5 3 $0.00519849$
$p < 1000$ 40 42 46 38 7 $0.00127014$
$p < 10^4$ 306 310 308 303 3 $1.77678 \times 10^{-5}$
$p < 10^5$ 2387 2402 2411 2390 7 $4.01226 \times 10^{-6}$
$p < 10^6$ 19617 19665 19621 19593 3 $4.38196 \times 10^{-7}$
$p < 10^7$ 166104 166230 166211 166032 3 $5.89336 \times 10^{-8}$
$p < 10^8$ 1440298 1440474 1440495 1440186 7 $1.96717 \times 10^{-9}$
$p < 10^9$ 12711386 12712499 12712314 12711333 3 $4.3115 \times 10^{-10}$
$p < 10^{10}$ 113761519 113765625 113764039 113761326 3 $6.23018 \times 10^{-11}$
$p < 10^{11}$ 1029517130 1029509448 1029518337 1029509896 7 $3.88107 \times 10^{-12}$
$p < 10^{12}$ 9401960980 9401979904 9401997000 9401974132 7 $4.73196 \times 10^{-13}$
$p < 10^{13}$ 86516370000 86516427946 86516367790 86516371101 3 $2.13443 \times 10^{-14}$

In this chart, “disuniformity” is defined as the sum of squares of the difference between the relative frequency of each digit and the expected relative frequency (i.e. 1/4). Note that the distribution becomes consistently more uniform as the upper bound for p increases.

AFAIK, the “winner” is always either 3 or 7, not 1 or 9. Maybe there's a counterexample for a higher order of magnitude, but I'd need a much faster prime-listing program to check. The first few rows have an interesting alternating 3-7 pattern, but it breaks down for $10^7$.

Well, I have to admit that I just don't know how to answer the question without brute-force computation or sheer luck. Maybe that's a lack of education, since I only have an M.S. in mathematics instead of a Ph.D. But then, @GregMartin has co-written an academic paper on the exact subject of “prime number races” (linked in his answer), and can only conclude that “3 or 7 is more likely to be correct”, so I don't know how an “average” person could reasonably be expected to know the answer.

Dan
  • 18,262
  • 1
    continuation of the table \begin{array} p<10^8&1440298& 1440474& 1440495& 1440186 \ p<10^9&12711386& 12712499& 12712314& 12711333 \ p<10^{10}&113761519& 113765625& 113764039& 113761326 \ p<10^{11}&1029517130& 1029509448& 1029518337& 1029509896 \ p<10^{12}&9401960980& 9401979904& 9401997000& 9401974132 \ p<10^{13}&86516370000& 86516427946& 86516367790& 86516371101 \end{array} – alex st Mar 13 '25 at 19:18
  • 1
    two more results \begin{array} fp<10^{14}& 801235218413& 801235615814& 801235612994& 801235303579 \ p<10^{15}& 7461142367846& 7461142986919& 7461142817661& 7461142250241 \end{array} As we can see still holds. It would take days to check to 10^{16} and further, so I stop with it. – alex st Mar 14 '25 at 17:12