Primes avoid repeating their last digit

Every prime after 5 ends in 1, 3, 7 or 9, a quarter each. So a prime ending in 1 should be followed by another ending in 1 a quarter of the time. Count them. It is nowhere near a quarter, and nobody noticed until 2016.

The rules, all of them. List the primes in order with a sieve, take the first so many, and for each prime and the one straight after it note the two last digits. The table shows, for each last digit, what share of the time the next prime ends in 1, 3, 7 and 9. Nothing here is random: these are counts.

For the first 100 million primes, this code's counts agree with the table published by Robert Lemke Oliver and Kannan Soundararajan in 2016 to within one in each of the sixteen squares (nine are identical). A prime ending in 1 is followed by another ending in 1 only 18.5% of the time. The bias fades as the primes get larger, but very slowly: try the slider. Each last digit on its own does come up a quarter of the time. The page counts up to 10 million primes in your browser; the larger counts take a few seconds.