|
Problems & Puzzles:
Puzzles
|
|
Puzzle 1287 Ties Between the Final Digits of
Primes
On Oct 14, 2026, G. L.
Honaker, Jr., sent me some lines for a possible
puzzle about ties among the final digits of primes.
He gave me an example:
digits
prime discoverer
[1,9] -> 2341 Eldar, Aug 2026
Following his idea, I extended it to all
combinations of two, three and four final digits
(1, 3, 7, 9), and used a Python program to
record, for each combination, the largest tie
and the number of ties up to a given limit.
Note: A tie
for the digits [a,b] occurs at a prime p ending
in a or b when, counting all primes ≤ p, as many
end in a as in b (for [1,9] see OEIS A399129).
For three or four digits, all the counts must be
equal at the same time.
Here are my results for all primes below
10^13:
| digits |
prime at
largest tie |
# ties |
|
Pairs |
| [1,9] |
9,999,980,034,511 |
5,481,292 |
| [7,9] |
9,999,032,171,987 |
543,069 |
| [1,7] |
9,949,311,529,961 |
965,185 |
| [3,7] |
9,522,271,290,377 |
3,755,428 |
| [1,3] |
9,004,483,237,181 |
890,554 |
| [3,9] |
8,884,100,818,763 |
689,198 |
|
Triples |
| [1,3,9] |
8,874,131,773,081 |
86 |
| [1,3,7] |
597,189,590,237 |
52 |
| [3,7,9] |
322,970,147 |
15 |
| [1,7,9] |
18,565,889 |
61 |
|
Quadruple |
| [1,3,7,9] |
none |
0 |
Counts of primes
below 10^13 ending in 1, 3, 7 and 9: 1:
86,516,370,000, 3: 86,516,427,946, 7:
86,516,367,790, 9: 86,516,371,101 Last prime
checked: 9,999,999,999,971
Q1. Can you
verify my results? Q2. Can you extend my
results?
Some theory
behind the table:
1)
Why the race is fair, yet biased.
By Dirichlet’s theorem (1837) and the prime
number theorem for arithmetic progressions, each
of the final digits 1, 3, 7 and 9 eventually
takes one quarter of the primes, so every race
is “fair” in the long run. Yet in 1853 Chebyshev
noticed that primes in non-square classes tend
to lead: modulo 10, the squares of the digits 1,
3, 7, 9 end in 1 or 9, so the digits 3 and 7
tend to stay slightly ahead of 1 and 9 most of
the time. This is the so-called Chebyshev
bias. It is only a tendency, not a rule: at
10^13 the digit 3 leads, but the digit 7 is
behind both 1 and 9. Littlewood (1914) proved
that such leads change infinitely often (for the
classical race mod 4), and Rubinstein and Sarnak
(1994), assuming the Generalized Riemann
Hypothesis and a linear-independence hypothesis
on the zeros, showed that each order of the
racers occurs for a positive proportion of the
time (in logarithmic measure), with a typical
gap of order √x / ln x. Since in a two-digit
race the difference changes by exactly one at
each prime of the race, every change of leader
forces a tie. This is why pairs like [1,9] and
[3,7] (both “square” or both “non-square”
digits) tie so often, while the “mixed” pairs,
which have to overcome the bias, tie less often.
2) Why triples are rare and a
quadruple tie may never happen. A
heuristic comes from random walks. A tie among k
digits requires k − 1 differences to vanish
simultaneously, which resembles a random walk in
k − 1 dimensions returning to the origin. By
Pólya’s theorem (1921), a random walk returns to
the origin infinitely often in dimensions 1 and
2, but in dimension 3 it is transient:
it returns only finitely many times, possibly
never. This matches the table: hundreds of
thousands to millions of ties for pairs
(dimension 1), only between 15 and 86 for
triples (dimension 2), and no quadruple tie
(dimension 3) below 10^13. The Chebyshev bias,
which tends to push 3 and 7 away from 1 and 9,
makes a four-digit tie even less likely. Of
course primes are not a random walk, and as far
as I know nobody has proved or disproved the
existence of a quadruple tie.
References:
A. Granville & G. Martin, “Prime Number Races”,
Amer. Math. Monthly 113 (2006). M.
Rubinstein & P. Sarnak, “Chebyshev’s Bias”,
Experimental Mathematics 3 (1994).
|
|
|
|

From Oct 31 to Nov 6, 2026 contributions came from Arnav Garg, Shyam
Sunder Gupta, Gennady Gusev
*** Arnav wrote:
Q1. I verified your table for all primes below 10^13 with my own program.
Every entry matches exactly: the largest tie and the number of ties for all
six pairs, the four triples and the quadruple, and the four digit counts
(86,516,370,000; 86,516,427,946; 86,516,367,790; 86,516,371,101).
Q2. I extended the table to all primes below 10^14. For each set of digits:
the prime at the largest tie, then the number of ties below 10^14.
| digits |
prime at largest tie |
# ties |
| Pairs |
| [3,7] |
99,999,671,975,443 |
13,453,456 |
| [1,9] |
97,030,298,270,749 |
16,501,159 |
| [7,9] |
84,910,130,630,657 |
4,182,243 |
| [1,7] |
84,848,865,388,967 |
3,386,588 |
| [3,9] |
74,882,616,820,939 |
1,606,581 |
| [1,3] |
60,160,878,559,513 |
1,811,223 |
| Triples |
| [1,3,7] |
31,664,127,091,951 |
58 |
| [1,3,9] |
8,874,131,773,081 |
86 |
| [3,7,9] |
322,970,147 |
15 |
| [1,7,9] |
18,565,889 |
61 |
| Quadruple |
| [1,3,7,9] |
none |
0 |
Counts of primes below 10^14 ending in 1, 3, 7 and 9: 1: 801,235,218,413,
3: 801,235,615,814, 7: 801,235,612,994, 9: 801,235,303,579
Last prime checked: 99,999,999,999,973
Arnav's program: ties.c (C source) and
check.py (brute-force checker)
Some observations:
- Triples: the only new triple ties between 10^13 and 10^14 are six [1,3,7]
ties: 30,976,504,019,467; 30,976,900,787,177; 31,664,127,024,581;
31,664,127,024,613; 31,664,127,091,483; and 31,664,127,091,951. The other
three triples have no new ties, so their largest ties are the same as below
10^13.
- Quadruple: there is still no [1,3,7,9] tie below 10^14.
- The [1,9] race: after the tie at 9,999,980,034,511 (your largest below
10^13), the next [1,9] tie is at 10,002,760,032,841.
- The order changed: at 10^13 the order was 3 > 9 > 1 > 7. At 10^14 it is 3
> 7 > 9 > 1, so the two "non-square" digits 3 and 7 now lead, as Chebyshev's
bias suggests.
Method: a C program with a segmented wheel-30 sieve of Eratosthenes. In a
64-bit word every bit stands for a number with a fixed last digit, so the
digit counts are popcounts. The program makes two passes. The first records,
for each block of numbers, the digit counts and the range each pair
difference can take. The second walks prime by prime only through the blocks
where a pair difference can reach zero.
Checks: the program matched a brute-force checker in many configurations up
to 6x10^7, matched OEIS A399129's first terms, reproduced pi(10^k) for k = 9
to 14, and reproduced your full 10^13 table. The range from 10^13 to 10^14
was computed starting from your counts at 10^13. It ran in 78 minutes on 32
cores of a lab server at BITS Pilani.
Some days later Arnav wrote again::
He extended the table to all primes below 10^15
| digits |
prime at largest tie |
# ties |
| Pairs |
| [3,7] |
993,574,639,133,227 |
38,489,939 |
| [1,9] |
976,824,964,453,159 |
44,299,021 |
| [1,3] |
892,492,021,178,221 |
5,447,396 |
| [1,7] |
888,766,489,646,141 |
9,193,171 |
| [7,9] |
573,602,686,237,499 |
11,059,063 |
| [3,9] |
467,174,133,400,069 |
6,961,815 |
| Triples |
| [1,3,7] |
887,590,916,963,293 |
85 |
| [1,7,9] |
189,850,188,530,659 |
66 |
| [1,3,9] |
162,829,242,636,919 |
170 |
| [3,7,9] |
322,970,147 |
15 |
| Quadruple |
| [1,3,7,9] |
none |
0 |
Counts of primes below 10^15 ending in 1, 3, 7 and 9:
1:
7,461,142,367,846, 3: 7,461,142,986,919, 7: 7,461,142,817,661, 9:
7,461,142,250,241 Last prime checked: 999,999,999,999,989
*** Shyam wrote:
Q1. Can you verify my results?
Your all results are verified and found correct.
Q2. Can you extend my results?
Extended results up
to 10^14 are given below:
(Shyam sent the same Table that already
Arnav sent & shown above. So, no need of repeating it)
***
Gennady wrote.
1. Confirm Carlos's results
2. Extending upto 1.5*10^13:
(2,3,4) count last prime
(1,3) 939366 10572283772371
(1,7) 1324192 13334989312031
(1,9) 6220377 14815439660929
(3,7) 4325464 14257093409147
(3,9) 689198 8884100818763
(7,9) 924651 10568473977407
(1,3,7) 52 597189590237
(1,3,9) 86 8874131773081
(1,7,9) 61 18565889
(3,7,9) 15 322970147
(1,3,7,9) 0 0
***
|