MathomalyA field guide to patterns, proofs and open questions

ExplorationsTwo teams of primes, one long lead, and the prime where it breaks

The Prime Race That Fixes Its Own Result

Conjecturedprimesresiduesanalytic number theoryintermediate Seen in Mathomaly No. 01 at 2:44

Chebyshev noticed that leaving 3 on division by 4 seem to lead those leaving remainder 1. Divide each prime by 4 and it leaves a remainder of 1 or 3, except for 2 itself. Counting the primes as they come, the remainder-3 team is ahead at 3, at 7, at 11 and at almost every stopping point anyone would try by hand. It is not ahead forever: at the prime 26,861 the remainder-1 team is in front for the first time, by one.

Interactive laboratory

Current view: The lead

Follow the difference between the two counts as the primes accumulate.

The lead · dividing by 4 · to 10,00010,000
Counting every prime up to 10,000 by its remainder on division by 4, with exact arithmetic.
the lead line
the remainder-1 count minus the other count, at each stopping point
the level line
where the two counts are equal, which is not a lead for either side
a lead zone
a stretch of primes where the remainder-1 count is strictly greater

The horizontal axis is the counting limit on a logarithmic scale, so equal distances are equal factors rather than equal amounts. The height is the remainder-1 count minus the other team’s count, and the level line at zero is where they are equal. Below the level line the other team leads. A shaded band marks a stretch where the remainder-1 count is strictly greater, and equal counts are never shaded, because equal is not ahead.

Counting every prime up to 10,000, 0% done.

Range
2 to 10,000
How this page is laid out

Make a prediction

primes

Change the assumption

What this assumes
Team 3, the primes leaving remainder 3, is always ahead.
What breaks it
The count reaches the prime 26,861. Team 1 then has one more prime than team 3, and the lead is lost again at the next prime, 26,863.
Where it holds

Every stopping point below 26,861: team 3 never has fewer primes than team 1, although the counts are level at 5, 17, 41 and 461.

How far to count

Twelve hundred primes, and the remainder-3 team is never behind at any of them.

Every prime in the range is counted exactly, in a background thread that reports its progress and can be stopped. Stopping reports nothing rather than reporting a partial count as a result. The ledger view prints the race to 100 whatever this is set to, because its rows are meant to be read.

One prime at a time

Only the prime-by-prime view plays: it walks the ledger one prime at a time, and its Step, Run and Reset buttons appear under that figure. The other views are summaries of the same walk, so they do not move. This sets the speed it runs at.

Speed

What to divide by

The divisor

Dividing by 4 splits the odd primes into remainders 1 and 3, and 2 joins neither team. Dividing by 3 splits them into remainders 1 and 2, and it is 3 that joins neither. The remainder-1 team is never strictly ahead in the modulus-3 race anywhere below ten million, although a crossing is proved to exist much further out.

Advanced parameters

A lead means strictly more, and this is the whole convention behind the number this page is named after. Counting equal as ahead would put the first lead at 5 rather than at 26,861, because the counts are level at 5, 17, 41 and 461 without the remainder-1 team ever getting in front.

Cases worth seeing

Try this

Before moving anything: at the largest limit this page offers, which team do you expect to be ahead, and by roughly how much?

1/4

What is going on

Each explanation begins with a worked example and follows the same operation through intuition, formal statements and proofs. Later sections distinguish what is established from questions that remain open, so you can follow the level of detail useful to you.

Worked by handThe to 13, sorted by the they leave on division by 4, with the standing written after each one as team 1 to team 3.
  1. 0 to 02 divides 4, so 2 joins neither team0 to 0Only that leave a of 1 or 3 are counted, and 2 leaves 2.
  2. 0 to 03 = 4 × 0 + 3, so team 3 scores0 to 1The first counted puts team 3 one ahead.
  3. 0 to 15 = 4 × 1 + 1, so team 1 scores1 to 1The counts are level. This is the first equality, and it is not a lead.
  4. 1 to 17 = 4 × 1 + 3, so team 3 scores1 to 2Team 3 is ahead again after three counted .
  5. 1 to 211 = 4 × 2 + 3, so team 3 scores1 to 3Team 3 leads by two, which is as far ahead as it has been.
  6. 1 to 313 = 4 × 3 + 1, so team 1 scores2 to 3Team 1 closes the gap without taking the lead, which is the pattern that holds for a long time.
The ledger view in the laboratory prints exactly these rows and keeps going. Run steps through the one at a time, so the standing on screen is always the standing after the last prime shown.
Team 3 is ahead at almost every stopping point, and the counts are level at 5, 17, 41 and 461 without team 1 ever getting in front. The first time it does is at the 26,861, and it stays in front for exactly one prime.
01

What you are seeing

Two counters, one per

Take the in order and divide each one by 4. Every prime except 2 leaves a of either 1 or 3, because a remainder of 0 or 2 would make the number even. So 3, 7, 11, 19 and 23 go to one counter and 5, 13, 17, 29 and 37 go to the other. The prime 2 divides 4 and joins neither counter; the ledger prints its row and says so.

The lead view plots the difference between the two counters, -1 count minus remainder-3 count, against how far the counting has gone. The horizontal axis is logarithmic, so the distance from ten thousand to a hundred thousand is the same as from a hundred thousand to a million. The level line across the middle is where the counters are equal.

The fourth view, which digit wins, turns from the teams to the way the are written. Write each prime out in and tally the digits 0 to 9 wherever they turn up. You are asked which digit is written most before the bars fill in, because the natural first guess is a tenth each, and the primes do not give it.

02

Why it starts to make sense

Ahead almost everywhere, by very little

Both counters end up close together. At ten million each of them is around three hundred and thirty thousand, and they differ by a few hundred. The difference is tiny in proportion and almost always has the same sign: the line stays below the level line nearly the whole way across.

That is the phenomenon worth naming, and it has one: a towards 3. It is not a statement that team 3 wins, because there is no finishing line, and it is not a statement that the gap grows, because the gap wanders up and down. It is a statement about how often the picture looks one way rather than the other, and even in that weakened form it takes real machinery to say precisely.

03

The key idea

The lead breaks at 26,861, and only strictly counts

Set the to thirty thousand. The line touches the level line at 5, at 17, at 41, at 461, at 26,833 and at 26,849, and each of those is a moment when the two counters are equal. None of them is a lead for team 1, because being level is not being ahead, and this page uses ahead to mean strictly more.

At 26,861 the -1 counter is genuinely larger, by one. That is the only below six hundred thousand at which it is. At 26,863, the next prime, the counters are level again, and team 3 takes the lead straight back. If you had checked every prime by hand up to 26,000 and concluded that team 3 always leads, you would have been wrong, and nothing in the two thousand nine hundred and forty-five primes below 26,861 would have warned you.

04

Formal statement

Counting , and what a means

Write for the number of with . The race 4 compares with , and the plotted height is

Dirichlet's says both counts are infinite, and the theorem for (de la Vallée Poussin, 1896) says their tends to 1. Neither says anything about the sign of . The computation on this page establishes exactly one thing about that sign, which is where it first becomes positive, and only for .

The is stated in terms of logarithmic density: the density of the set measured with weight rather than . Rubinstein and Sarnak computed that density as approximately 0.9959, conditionally.

05

What is proved, and by whom

Two conditions attached to the famous number

Littlewood proved in 1914 that changes sign infinitely often. That is a , it is cited in the ledger, and it settles that no amount of counting can establish which team leads in the long run: there is no long run in which one of them does.

The density 0.9959 is a different kind of statement and carries two . Rubinstein and Sarnak's result assumes the generalised Riemann hypothesis, and separately assumes that the imaginary parts of the relevant zeros are linearly independent over the rationals. Neither is proved. The number is therefore quoted here as a conditional result and is marked conjectured in the claim ledger, not because the mathematics is loose but because its hypotheses are open.

The -3 crossing at 608,981,813,029 is a third kind of statement again: a computation somebody else ran, reported by Bays and Hudson in 1978. This page has not checked it and could not, and the claim scope says so.

The digit view rests on two different kinds of statement. That every except 2 and 5 ends in 1, 3, 7 or 9 is proved in a line: a number ending in 0, 2, 4, 6 or 8 is even, and one ending in 0 or 5 is a multiple of 5. That those four endings share the primes a quarter each in the long run is a too, the prime number theorem for (de la Vallée Poussin, 1896), and it is cited here, not proved. The shares the bars show are neither: they are exact counts, over every prime below the .

06

Limits and further questions

A figure that shows a computation failing

Switch to the -3 view. Nothing is shaded anywhere across the whole figure, because the -1 count is never strictly greater at any point below ten million. It would be easy to read that as evidence that it never is, and it is the opposite: a crossing is proved to exist, and the first one is quoted at roughly sixty thousand times the right-hand of this figure. So this is a computation shown failing to find something that is known to be there, which is the most useful thing a finite scan can be used for.

Two questions the page cannot answer. How large does the lead get? Below ten million the largest is eight, and there is no reason from the figure to think that is close to a ceiling, because Littlewood's says the swings are unbounded. And how much of the time is each team ahead? That is the density question, and it is exactly the one whose answer is conditional.

The digit view invites a similar caution. Below a hundred million the digit 1 is written most and 0 least, with 12.15% and 7.47% of all the digits written, and the gap between the largest and the smallest share has narrowed at every step from a thousand. The unevenness sits at the two ends of each : the last digit is only ever 1, 3, 7 or 9, and the first is never 0 and leans towards the small digits because primes thin out as numbers grow. The digits in the middle sit within 0.02 percentage points of a tenth each. That is the reason to expect every share to drift towards 10% as primes get longer, and it is an , marked as a in the claim ledger. A count to a hundred million shows a trend and cannot show where it ends.

What is actually established

Every statement on this page, with its status, its exact scope, and the date that status was last checked.

Exhaustively checked

Counting primes by their remainder on division by 4, the remainder-1 count first strictly exceeds the remainder-3 count at the prime 26,861, where it leads by one.

Scope
Every prime up to 10,000,000, counted in order. Strictly exceeds is meant strictly: the counts are equal at 5, 17, 41, 461, 26,833 and 26,849, and an equality is not a lead. The prime 2 divides 4 and is counted on neither team. Below 26,861 the remainder-3 count is never smaller than the remainder-1 count. This says nothing about primes above ten million.
Why
The kernel sieves to ten million in segments and increments one of two counters for each prime as it passes, so the counts are exact integers rather than estimates. The lead is lost again at the very next counted prime, 26,863, and does not return until 616,841.
Computation (exact)
All 664,579 primes below 10,000,000, by segmented sieve of Eratosthenes, with a lead recorded only where one count strictly exceeds the other. Algorithm primeRaces.raceTo v1.
Status checked
Proved

The difference between the two counts changes sign infinitely often, so neither team leads from some point onwards.

Scope
The full infinite sequence of primes, for the modulus-4 race. Proved in the cited note of 1914 and not proved here; this page computes a finite range and cites the theorem for everything beyond it.
Why
Littlewood showed that the difference oscillates without bound in both directions. Any finite scan, including this page’s ten million, therefore reports one side leading for reasons of where it happened to stop rather than for any reason that lasts.
Status checked
Sources
Sur la distribution des nombres premiers citation unresolved
Conjectured

The set of x at which the remainder-3 count exceeds the remainder-1 count has logarithmic density approximately 0.9959.

Scope
A conditional result of Rubinstein and Sarnak, 1994, for the modulus-4 race. It assumes the generalised Riemann hypothesis and, separately, that the imaginary parts of the relevant zeros are linearly independent over the rationals. Neither assumption is proved, so the density is not an established fact and is not presented as one. Logarithmic density is not ordinary proportion, and this page computes neither.
Why
The number says that team 3 is ahead almost all the time in a weighted sense, which is consistent with the two narrow stretches this page finds below ten million. It is quoted as a conditional theorem, not as a measurement of the figure on screen.
Status checked
Sources
Chebyshev’s bias citation unresolved
Proved

In the modulus-3 race, the first x at which the remainder-1 count exceeds the remainder-2 count is 608,981,813,029.

Scope
The literature’s number, attributed to Bays and Hudson, 1978, and not checked here. This page counts to ten million, roughly sixty thousand times short of it, and finds no crossing, which is consistent with the cited value and is not evidence for it. The citation is unverified against its printed record.
Why
Two separate things are being said. That some crossing exists follows from Littlewood’s theorem. Where the first one is was found by computation reported in the cited paper, and the figure on this page can only show that it is not below ten million.
Status checked
Exhaustively checked

Below ten million the remainder-1 team leads over exactly two stretches: the single prime 26,861, and a broken run of primes between 616,841 and 633,797.

Scope
Every prime up to 10,000,000, modulus 4. The second stretch is not continuous: the lead is taken and lost many times inside it, and the figure shades each piece separately. The largest lead reached anywhere in the range is eight.
Computation (exact)
All 664,579 primes below 10,000,000, by segmented sieve, recording every maximal run of primes over which one count strictly exceeds the other. Algorithm primeRaces.raceTo v1.
Status checked
Proved

Every prime other than 2 and 5 ends in 1, 3, 7 or 9.

Scope
All primes, in decimal. The argument is the whole proof: a number ending in 0, 2, 4, 6 or 8 is even, and a number ending in 0 or 5 is a multiple of 5, so the only primes among them are 2 and 5 themselves. The digit view checks it against every prime below a hundred million, which adds nothing to the proof.
Status checked
Proved

The primes ending in 1, 3, 7 and 9 each make up a quarter of all primes, in the sense that the count of each, up to x, divided by the count of all primes up to x, tends to 1/4 as x grows.

Scope
The full infinite set of primes, in decimal. This is the prime number theorem for arithmetic progressions (de la Vallée Poussin, 1896) applied to the modulus 10, and it is cited here, not proved. The digit view measures each share at six limits, each within 0.06 percentage points of a quarter from a million upwards, and that is evidence of the size of the shares at those limits and not part of the argument.
Why
Dirichlet showed in 1837 that each of the four classes contains infinitely many primes. That they share the primes evenly in the long run is the stronger statement, and it belongs to the prime number theorem for arithmetic progressions (de la Vallée Poussin, 1896).
Status checked
Sources
Multiplicative Number Theory citation unresolved
Exhaustively checked

Counting every digit of every prime below a limit, the commonest digit is 1 and the rarest is 0 at each limit from ten thousand to a hundred million, and the gap between the largest and the smallest share narrows at every step. The first digit is never 0, and from a million upwards its share falls at every step from 1 to 9. The middle digits are each within 0.02 percentage points of a tenth below a hundred million.

Scope
Every prime below 1,000, 10,000, 100,000, 1,000,000, 10,000,000 and 100,000,000, written in decimal. Below 1,000 the digits 1 and 7 are tied for most written, so the statement starts at ten thousand. The shares are read from the counts and not fitted. Nothing here is said about primes above a hundred million, or about whether the gap closes completely.
Why
The gap between the largest and the smallest share of the digits is 13.26 points below a thousand and 4.68 below a hundred million. The two ends of each prime are where the unevenness comes from: a last digit of 1, 3, 7 or 9 and a first digit that is never 0.
Computation (exact)
All 5,761,455 primes below 100,000,000, by segmented sieve of Eratosthenes, with integer arithmetic for every digit and every share quoted from an exact count. Algorithm primeDigits.digitTalliesBelow v1.
Status checked
Heuristic

As primes get longer, each digit’s share of all the digits written tends to a tenth.

Scope
A model, not a theorem, and nothing on this page proves it. The reasoning is that the unevenness lives at the two ends of each prime, which is two digits out of a length that keeps growing, while the digits in between look evenly spread, as the counts below a hundred million show. A finite count cannot establish a limit, so the figure shows the trend and this page does not claim the destination.
Status checked

Sources

Review notes show which bibliographic details Mathomaly has checked and which remain unresolved. Checking a publication record does not independently verify its proof.

  1. John Edensor Littlewood, Sur la distribution des nombres premiers, Comptes Rendus de l’Académie des Sciences, Paris, volume 158, 1914.

    The note in which the difference between the two counts is shown to change sign infinitely often, so no finite computation can settle which team leads in the long run. Cited for that theorem; the argument is not reproduced on this page.

    Citation details remain unresolved after review by Mathomaly.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: unresolved.

    Volume, year and title are taken from the standard secondary attributions of the sign-change theorem. Neither the original Comptes Rendus issue nor a publisher record for it was opened, so the page numbers are not stated and the identity remains unconfirmed.

  2. Michael Rubinstein, Peter Sarnak, Chebyshev’s bias, Experimental Mathematics, volume 3, number 3, 1994.

    Gives the logarithmic density of the set where the residue-3 team leads modulo 4, approximately 0.9959. The result is conditional on the generalised Riemann hypothesis together with a linear independence assumption on the imaginary parts of the zeros, and this page states both conditions wherever the number appears.

    Citation details remain unresolved after review by Mathomaly.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: unresolved.

    Journal, volume and year are taken from secondary citations of the conditional density result. The article itself was not opened, so neither the value 0.9959 nor the exact statement of the two hypotheses has been checked against the printed text.

  3. Carter Bays, Richard H. Hudson, On the fluctuations of Littlewood’s theorem on primes, Mathematics of Computation, volume 32, 1978.

    The source of the value 608,981,813,029 for the first crossing in the modulus-3 race. That figure is quoted from the literature and is far beyond anything this page computes, so the claim citing it is scoped to say exactly that.

    Citation details remain unresolved after review by Mathomaly.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: unresolved.

    Authors, journal and year are taken from secondary citations of the modulus-3 crossing value. The paper was not opened and the crossing was not recomputed here, so the number is attributed rather than verified.

  4. Harold Davenport, Multiplicative Number Theory, Springer, Graduate Texts in Mathematics 74, 1980. Link

    A standard textbook treatment of Dirichlet’s theorem and of the prime number theorem for arithmetic progressions, the result that gives the primes ending in 1, 3, 7 and 9 a quarter each in the long run. Cited for that theorem; the argument is not reproduced on this page.

    Citation details remain unresolved after review by Mathomaly.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: unresolved.

    The DOI registry record confirms the author, the title, the publisher, the series Graduate Texts in Mathematics and 1980. The book was not opened, so that the prime number theorem for arithmetic progressions is in it, and where, rests on the standard attribution and is not confirmed here. The same edition and the same status are recorded for the prime-neighbours page.

Connected by how they work, not by sharing a topic label.