THE PRIME ATLAS
The Prime Atlas
Last digits 1, 3, 7 and 9 appear about 25% each. Yet consecutive primes are less likely to share the same ending. Explore this surprising bias with diagrams, questions and data up to 1 million.
Primes may look random, but their order has quirks. Start with the rightmost digit: each ending appears about equally often, yet the same ending is less likely to repeat. How can both be true?
About 25% each. Yet less likely to repeat.
Primes greater than 5 end in one of four digits: 1, 3, 7 or 9. Up to 1 million, each accounts for about 25%. But after a prime ending in 1, the next prime also ends in 1 only about 16.38% of the time. Equal frequencies do not imply an independent order.
Calculated from the 78,495 primes greater than 5 and up to 1 million, and the 78,494 consecutive pairs within that sample. The 25% share is a limit approached as the range grows; a finite sample differs slightly.
After a 1, which digit comes next?
Group consecutive primes by the first prime’s last digit, then count the next ending. For example, “1 → 3” is the percentage of primes ending in 1 whose successor ends in 3. The gold cells show repeated endings. Every one is below 25%.
| Previous ↓ / Next → | 1 | 3 | 7 | 9 |
|---|---|---|---|---|
| 1 | 16.38 | 32.11 | 33.39 | 18.12 |
| 3 | 22.31 | 14.29 | 29.59 | 33.80 |
| 7 | 25.83 | 27.74 | 14.64 | 31.78 |
| 9 | 35.46 | 26.09 | 22.34 | 16.10 |
Scroll the table horizontally on a narrow screen.
If four endings were chosen independently with a 25% chance each, repeats would also occur 25% of the time. In this prime sample, all same-ending pairs together account for only about 15.35%. Equal overall frequencies and independence from the previous digit are different properties.
Can the same ending ever repeat?
Yes. The next prime after 181 is 191, and both end in 1. “Less likely to repeat” describes a statistical bias across many pairs, not a ban on individual repeats.
A closer look at the counts
There are 19,617 primes ending in 1; 19,664 ending in 3; 19,621 ending in 7; and 19,593 ending in 9. Divide by 78,495 to get 24.99%, 25.05%, 25.00% and 24.96%.
The transition table only includes pairs whose two primes both lie within the range. The final prime, 999,983, has no successor inside the sample, so the denominator for the row starting with 3 is 19,663. The other row totals are 19,617, 19,621 and 19,593. Percentages are rounded to two decimal places.
A pattern that simple counting hides.
First, why about 25% for each ending?
A prime greater than 5 is divisible by neither 2 nor 5. That rules out endings 0, 2, 4, 5, 6 and 8, leaving 1, 3, 7 and 9.
Having four possibilities is not, by itself, proof of equal frequencies. A mathematical result—the prime number theorem for arithmetic progressions—shows that each of these four shares tends to 1/4 as the range grows. See the statement in MIT’s course notes, Problem 5.
Counting individual endings resembles four equally likely choices. The theorem does not say that consecutive endings are independent.
Then why are repeated endings less common?
A prime cannot be divisible by a smaller prime. For two primes to be consecutive, there must also be no other prime between them. These conditions together are related to the bias in their endings.
616771
61 and 71 share an ending, but 67 lies between them, so they do not form a consecutive pair. This illustrates what “consecutive” means. Merely noting that equal endings must be at least 10 apart does not explain the size of the observed bias.
In 2016, Lemke Oliver and Soundararajan studied this bias in detail. Their conjectural explanation combines divisibility restrictions with the absence of an intervening prime. The quantitative account relies on the unproven Hardy–Littlewood prime-tuples conjecture. Read their paper on biases in consecutive primes.
The last-digit frequencies are nearly equal. Their order still has a bias. A seemingly random sequence reveals an unexpected regularity.
What exactly is a prime?
A prime is an integer at least 2 whose only positive divisors are 1 and itself. There are 25 primes from 1 to 100, shown in gold below.

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97. The only even prime is 2.
Six more surprises to explore.
Another prime, close by.
Primes that differ by 2, such as 11 and 13, are called twin primes. Just one integer sits between them.
How many pairs are there up to 100?
Eight: (3, 5), (5, 7), (11, 13), (17, 19), (29, 31), (41, 43), (59, 61) and (71, 73). The number 5 appears in two pairs.
Whether infinitely many such pairs exist is still an open problem. The twin prime conjecture.
Try it: generate primes from 2 to 100 and look for gaps of 2.
Suddenly, they disappear.
The next prime after 113 is 127. Between them lie 13 nonprime integers. 119 is 7×17, and 121 is 11×11. An odd number need not be prime.
Can a gap be even longer?
Arbitrarily long runs without a prime exist. For example, let N = 1×2×…×10. Then N+2 is divisible by 2, N+3 by 3, and so on through N+10. A longer product creates a longer consecutive run of composite numbers.
Try it: generate primes from 100 to 200 and find the longest gap.
A spiral reveals a pattern.
Arrange integers in a spiral from a central 1, then mark the primes. Diagonal streaks begin to appear. This arrangement is called the Ulam spiral. How the spiral works.
Is every number along a streak prime?
No. The apparent streaks also contain nonprime positions. Changing the arrangement makes a bias visible that is much harder to notice in an ordinary list.
Try it: generate primes from 2 to 3,721 and plot their positions on a square spiral.
Further out, fewer encounters.
These three intervals each contain 1,000 integers, yet their prime counts fall from 168 to 106 to 81. Overall, primes become sparser as the numbers grow. The distribution of primes.
Does every next interval have fewer primes?
No. Local counts rise and fall. Comparing the broad trend with the variation between individual intervals is part of the exploration.
Try it: choose several equal-width intervals and compare their prime counts.
A formula with a 40-prime streak.
Substitute 0, 1, 2… into n²+n+41. For n = 0 through 39, all 40 results are prime. This is a famous formula associated with Euler. About the formula.
What happens when n is 40?
40²+40+41 = 1681 = 41×41. The streak of primes ends. A formula that works repeatedly need not keep working forever.
Try it: generate primes from 2 to 1,700 and compare them with the formula’s values.
The same, read either way.
Numbers such as 131 and 313 read the same in either direction. They are palindromes; those that are also prime are palindromic primes. Even the digits’ appearance offers something to explore. Palindromic primes.
Is 121 a palindromic prime, too?
It is a palindrome, but not a prime: 121 = 11×11. Every decimal palindrome with an even number of digits is divisible by 11, making 11 the only prime among them. Why 11 is special.
Try it: generate primes from 2 to 1,000 and look for numbers with mirror symmetry.
Explore your own range, on your PC.
Investigate primes near large values or create datasets too cumbersome to download. Choose the range you need and generate it locally. Generate large primes and lists →
In Riragon Prime Generator, set the start to 6 and the end to 1000000, then save as TXT to reproduce this list of 78,495 primes. Last-digit and consecutive-pair counts are examples of analyzing exported data in a spreadsheet or your own program. Follow the counting steps.
Find twins in a small range, compare counts and gaps, or rearrange the exported numbers to draw a spiral.
The CLI in development version 1.0.6 also provides gaps for gaps and twin pairs, density for counts by interval, and probe for saved primes immediately around a chosen value.
