Skip to content
Riragon Prime Generator Windows StoreTry free for 7 days
← Prime Generator

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?

IN FOCUS · THE LAST-DIGIT MYSTERY

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.

Up to 1 million, last digits 1, 3, 7 and 9 occur at 24.99%, 25.05%, 25.00% and 24.96%. The next prime repeats the same ending at 16.38%, 14.29%, 14.64% and 16.10%, respectively—below the independent 25% baseline. Last-digit frequencies: 1 at 24.99%, 3 at 25.05%, 7 at 25.00%, 9 at 24.96%. Conditional repeat rates: 1 to 1 at 16.38%, 3 to 3 at 14.29%, 7 to 7 at 14.64%, 9 to 9 at 16.10%.

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.

LOOK AT THE ORDER.

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%.

Next-digit frequencies, conditional on the previous digit (%)
Previous ↓ / Next →1379
116.3832.1133.3918.12
322.3114.2929.5933.80
725.8327.7414.6431.78
935.4626.0922.3416.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.

WHY DOES THIS HAPPEN?

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.

The integers from 1 to 100 in a ten-by-ten grid, with 25 primes in gold. 1 is not prime; 2 is the only even prime.

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.

01 · TWINS

Another prime, close by.

Twin prime pairs 3 and 5, 5 and 7, 11 and 13, 17 and 19. Each pair differs by 2.

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.

02 · LONG GAPS

Suddenly, they disappear.

113 and 127 are consecutive primes, with a gap of 14. The 13 integers from 114 through 126 are all nonprime.

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.

03 · A SKY OF NUMBERS

A spiral reveals a pattern.

Starting with 1 in the center, integers spiral right, up, left and down. Marking primes in the 61-by-61 grid from 1 to 3,721 reveals diagonal streaks.

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.

04 · A THINNING FOREST

Further out, fewer encounters.

Three intervals of 1,000 integers: 1–1,000 has 168 primes, or 16.8%; 10,001–11,000 has 106, or 10.6%; 100,001–101,000 has 81, or 8.1%.

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.

05 · THE MAGIC OF 41

A formula with a 40-prime streak.

The 40 values of n squared plus n plus 41 for n from 0 through 39. Beginning 41, 43, 47, 53 and ending at 1,601, all are prime.

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.

06 · PRIMES IN THE MIRROR

The same, read either way.

131, 151, 181, 313, 353 and 373. Each is prime and reads the same backwards.

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.

YOUR NEXT DISCOVERY.

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.

How to generate a list →About the app →