← All projects / The Race

The race

Divide every prime by some number m and sort them by remainder. The teams finish almost level, as they must. But it isn't a fair race: the remainders that aren't perfect squares mod m stay a little ahead nearly all the time. Pick a divisor and watch it, prime by prime, up to 10 million.

Watch one race

non-squares aheadsquares ahead

Move along the chart to read the lead.

Remainders are counted from 1 to m, with m standing where 0 would. The lead is the average count in a non-square remainder minus the average in a square one, so remainders with different numbers of members compare fairly. Across, each mark is 10 times the one before.

All nineteen at once

Touch one to watch it above.

What's going on

In the end it's a tie

Dirichlet proved in 1837 that the primes share out evenly among the remainders that share no factor with m. The leads above are a few hundred out of more than 660,000 primes, a few hundredths of a percent.

But the squares start behind

Chebyshev noticed the lean in 1853. The usual picture: count the squares of the primes along with the primes and the race comes out fair, but a prime's square always lands on a square remainder. So the primes on their own lean towards the non-squares.

They do overtake, rarely

Mod 4, the squares first take the lead at 26,861, found by Leech in 1957. Mod 3 it takes until 608,981,813,029 (Bays and Hudson, 1978), far past this chart. Rubinstein and Sarnak worked out in 1994 that, measured the right way, the non-squares lead mod 4 about 99.59% of the time, but not always.

Bigger divisors race closer

The lean gets weaker as m grows and the remainders multiply. Mod 19 the squares are ahead for about a third of the primes up to 10 million, and the lead changes hands more than 1,800 times.