Abakcus

← All articles

Archive Number theory · Primes

Interesting Prime Numbers and Prime Number Facts

A growing archive of the strangest primes and the rules every prime obeys, each one checked, proved where it can be, and drawn. Test any number with the checker, or open the catalogue below.

Entries
10
Proven
6
Figures
10
Updated
Nov 2026
Prime checker · test any numberup to 40 digits
PrimeThe 17,494th prime number.
Circular primeEmirp · reversed 939,391 is primeTwin prime with 193,937 6k + 1 with k = 32,323
Previous primeNext prime

The 25 primes below 100 · tap any square

The catalogue 10 entries · tap a row to open it

No.NumberEntryKindStatus
0173,939,133The largest right-truncatable primeChop digits off the end one at a time and every number left is prime, all the way down to 7.73,939,133SpecimenComplete list
026k ± 1Every prime after 3 is next to a multiple of 6Add 1 or subtract 1 from any prime above 3 and you hit a multiple of 6. It never fails.6k ± 1RuleProven
0399…900…01A pattern that holds nine times, then breaksComposite, prime, composite, prime, for nine rows. The tenth row should be prime and is not.99…900…01PatternComputed
041 0¹³ 666 0¹³ 1Belphegor’s primeA 31-digit palindromic prime with 666 in the middle and thirteen zeros on each side.1 0¹³ 666 0¹³ 1SpecimenProven prime
0523,456,789The largest prime with consecutive rising digitsIts digits climb one step at a time from 2 to 9, and no bigger prime does that.23,456,789SpecimenComplete list
06n² − n + 41Euler’s prime-generating polynomialForty primes in a row from one formula, and still six times the normal rate a million steps later.n² − n + 41PatternComputed
07193,939A circular primeMove its first digit to the back, again and again: all six rotations are prime.193,939SpecimenProven
08(p, p)Primes drawn in polar coordinatesPlot each prime at distance p and angle p: a swirl at 5,000 primes, 280 straight rays at 50,000.(p, p)PictureExplained
097 → 8The only prime followed by a cube7 sits right before 8 = 2³, and a one-line factorisation shows no other prime ever can.7 → 8RuleProven
101,234,567,891Primes that count upwardCount 1, 2, 3 … 9, wrap round, stop on a 1: at 10 and 28 digits the result is prime.1,234,567,891PatternComputed

73,939,133

The largest right-truncatable prime

Digits
8
Family size
83 primes
Ends with
1, 3, 7 or 9
Catalogue
OEIS A024770

In one lineChop digits off the end one at a time and every number left is prime, all the way down to 7.

73,939,133 is prime. Remove the last digit and you get 7,393,913, also prime. Remove another and 739,391 is prime too. Keep going, all the way down to a single 7, and you never land on a composite number.

Fig. 1 · Truncation ladder
73939133prime
73939133prime
73939133prime
73939133prime
73939133prime
73939133prime
73939133prime
73939133prime
Remove the last digit, eight times over. Every number left standing is prime.

Numbers like this are called right-truncatable primes. There is a simple reason they are rare: once you are past the first digit, the only digits you can ever add on the right are 1, 3, 7 and 9. An even last digit makes the number divisible by 2, and a 5 makes it divisible by 5. So every step up the ladder is a gamble on four choices, and as numbers grow, primes thin out.

The gamble eventually fails for every branch. Start from 2, 3, 5 and 7, try every allowed digit on the right, keep only the primes, and repeat. The tree of survivors stops growing after eight digits. In total there are exactly 83 right-truncatable primes, and 73,939,133 is the last and largest of them. Add any digit to its right (739,391,331, 739,391,333, 739,391,337 or 739,391,339) and none of them is prime.

That “exactly” is the striking part. Most questions about primes have no last answer: there is no largest prime, and nobody knows whether the twin primes ever run out. This one has a finished, complete list, and a computer can check all of it in a fraction of a second.

6k ± 1

Every prime after 3 is next to a multiple of 6

Applies to
Every prime > 3
Proof length
Three lines
Bonus
p² − 1 ÷ 24
Catalogue
OEIS A007310

In one lineAdd 1 or subtract 1 from any prime above 3 and you hit a multiple of 6. It never fails.

Pick any prime number bigger than 3. Either add 1 to it or subtract 1 from it, and one of the two results will be a multiple of 6. Take 5: add 1 and you get 6. Take 7: subtract 1 and you get 6. Then 11 and 13 sit on either side of 12, 17 and 19 on either side of 18, and 23 is one short of 24. It never fails, no matter how large the prime.

Fig. 2 · Six columns
6k + 1even÷ 3even6k − 1÷ 6123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
The numbers 1 to 60, six to a row, primes in black. After 2 and 3, every prime falls in the first or fifth column. The white squares in those columns are the ones that are not prime.

The proof takes three lines. Divide any whole number by 6 and the remainder is 0, 1, 2, 3, 4 or 5, so every number has one of six shapes: 6k, 6k + 1, 6k + 2, 6k + 3, 6k + 4 or 6k + 5. Three of those, 6k, 6k + 2 and 6k + 4, are even. A fourth, 6k + 3, is divisible by 3. A prime bigger than 3 can be neither, so only 6k + 1 and 6k + 5 are left, and 6k + 5 is the same thing as one less than the next multiple of 6. That is why mathematicians write the rule as 6k ± 1.

The rule only runs one way. Every prime after 3 has the form 6k ± 1, but not every number of that form is prime: 25 is one more than 24 and 35 is one less than 36, and both are divisible by 5. Those are the white squares in the grid. The rule tells you where primes are allowed to live, and says nothing about which of the allowed spots are occupied.

Two more facts fall out of it for free. Twin primes are pairs that differ by 2, such as 11 and 13 or 29 and 31. Apart from 3 and 5, the number between any pair of twins must be a multiple of 6, because it is the only way both neighbours can fit the rule. And if you square any prime bigger than 3 and subtract 1, the result is always divisible by 24: 5² − 1 = 24, 7² − 1 = 48, 11² − 1 = 120, 13² − 1 = 168. Writing the prime as 6k ± 1 gives p² − 1 = 12k(3k ± 1), and one of k and 3k ± 1 is always even.

It is useful as well as tidy. A program testing whether a number is prime does not need to try every possible divisor. After checking 2 and 3, it can skip straight along 5, 7, 11, 13, 17, 19 and so on, testing only one number in every three.

99…900…01

A pattern that holds nine times, then breaks

Holds for
9 rows
Breaks at
Row 10
Primes found
4
Searched
First 400 rows

In one lineComposite, prime, composite, prime, for nine rows. The tenth row should be prime and is not.

Write down some nines, then one fewer zeros, then a 1. One nine gives 91, which is 7 × 13, so it is composite. Two nines give 9901, which is prime. Three give 999,001, composite again. Four give 99,990,001, prime again. Keep going and the answers take turns with perfect manners: composite, prime, composite, prime.

Fig. 3 · Nine in a row
nnumberverdict
1917 × 13
29901prime
399900119 × 52,579
499990001prime
599999000017 × 13 × 211 × …
6999999000001prime
7999999900000017² × 13 × 127 × …
89999999900000001prime
999999999900000000170,541,929 × …
1099999999990000000001breaks · 61 × 9901 × …
Composite, prime, composite, prime, nine rows running. The tenth row was due to be prime and is not.

After nine rows anyone would bet on the tenth. Ten nines, nine zeros and a 1 should be prime, and it is not: 99,999,999,990,000,000,001 = 61 × 9901 × 4,188,901 × 39,526,741. The pattern does not bend, it simply stops. And one of the numbers that kills it is 9901, the very first prime on the list.

Half of the pattern is real and half is luck. With x = 10ⁿ, the number in row n is x² − x + 1. In rows 1, 5, 7, 11 and every other row that 2 and 3 do not divide, that expression is always divisible by 7 and by 13, which is why 91 = 7 × 13 keeps reappearing as a factor. So most odd rows are composite for a reason, and that half would have held forever.

The even rows had no such guarantee. Rows 2, 4, 6 and 8 just happened to be prime. Row 10 fails because 10 has 5 as a factor, and that lets the row 2 number divide it. The same trick sinks every row with a factor other than 2 and 3, so the only rows that still have a chance are 12, 16, 18, 24 and so on. A computer check of the first 400 rows finds no fifth prime. As far as that search goes, 9901, 99,990,001, 999,999,000,001 and 9,999,999,900,000,001 are the whole family.

It is the standard warning about primes in miniature. Nine confirmations are not a proof, and a pattern that looks like a law can be four coincidences in a row.

1 0¹³ 666 0¹³ 1

Belphegor’s prime

Digits
31
Palindrome
Yes
Found by
Harvey Dubner
Catalogue
OEIS A232449

In one lineA 31-digit palindromic prime with 666 in the middle and thirteen zeros on each side.

1,000,000,000,000,066,600,000,000,000,001 is a prime number, and it looks as if somebody designed it to be unsettling. It starts with a 1, runs through thirteen zeros, reaches 666 in the middle, then thirteen more zeros and a final 1.

Fig. 4 · Thirty-one digits
Thirty-one digits, the same read from either end, with 666 in the exact middle and thirteen zeros on each side.

Every part of it carries a superstition. 666 is the number of the beast. Thirteen is the unlucky number, and it appears twice. The whole thing is 31 digits long, which is 13 backwards. It is also a palindrome, the same forwards and backwards, so it belongs to the family of palindromic primes along with 11, 101 and 131.

The prime was found by Harvey Dubner, an engineer who spent decades hunting for unusual primes on custom hardware. The name came later. It refers to Belphegor, one of the seven princes of Hell in demonology and, fittingly, the demon credited with helping people make ingenious discoveries.

In compact form the number is 10³⁰ + 666 × 10¹⁴ + 1. Nothing forces thirteen to be the count of zeros; you can pad 666 with any number of zeros on each side and ask whether the result is prime. With no zeros you get 16,661, which is prime. With one to twelve zeros a side, every number is composite. Thirteen is the first padding that works again, and after it the next ones are 42, 506 and 608 zeros a side. So the devilish look is a coincidence, but a well-placed one.

23,456,789

The largest prime with consecutive rising digits

Digits
8
Candidates
36 runs
Family
23, 67, 89, 4567, 23456789
Status
Complete

In one lineIts digits climb one step at a time from 2 to 9, and no bigger prime does that.

23,456,789 is prime, and its digits climb one step at a time, from 2 up to 9. No larger prime does that. It is the biggest number of its kind that is prime.

The search is shorter than it sounds. Digits that rise one at a time, without wrapping back to 0, must be a run cut out of 123456789, so there are only 36 candidates with two or more digits. The longest, 123,456,789, has digits that add up to 45, and any number whose digits add up to a multiple of 3 is itself a multiple of 3. Of the two eight-digit runs, 12,345,678 is even. That leaves 23,456,789, and it happens to be prime.

Fig. 5 · Rising digits
123456789digits add to 45 → divisible by 3
12345678even
23456789prime
1234567127 × 9721
2345678even
3456789digits add to 42 → divisible by 3
The six longest runs of consecutive digits. Only one survives.

The full list of primes made this way is tiny: 23, 67, 89, 4,567 and 23,456,789. Five numbers, and the gap between the last two is the widest jump of all.

n² − n + 41

Euler’s prime-generating polynomial

First noted
Euler, 1772
Run of primes
n = 1 to 40
Prime share, n ≤ 10⁶
26.1%
Catalogue
OEIS A005846

In one lineForty primes in a row from one formula, and still six times the normal rate a million steps later.

In 1772 Leonhard Euler noticed something odd about the formula n² − n + 41. Put in n = 1 and you get 41, a prime. n = 2 gives 43, n = 3 gives 47, then 53, 61, 71, 83, 97, and on through forty values in a row, ending at 1,601 for n = 40. Every single one is prime.

The run has to end, and it ends at n = 41, where the formula gives 41² − 41 + 41 = 41² = 1,681. That is no accident: no polynomial with whole-number coefficients can produce only primes, because once n reaches the value of the constant term, that constant divides the result.

What is surprising is how long the formula keeps beating the odds after it breaks. Take every n from 1 to a million and about 26% of the results are prime: 261,081 out of 1,000,000. Numbers of the same size, picked at random, are prime only about 3.9% of the time. Euler’s formula finds primes more than six times as often as chance would.

Fig. 6 · Share of outputs that are prime
n ≤ 40100%
n ≤ 10086%
n ≤ 1,00058.1%
n ≤ 10,00041.5%
n ≤ 100,00032%
n ≤ 1,000,00026.1%
random3.9%
Share of the values n² − n + 41 that are prime, for n from 1 up to each limit. The last bar is how often random numbers of the same size are prime.

The reason is that the formula never hits small divisors. Its values are always odd, and none of them is divisible by 3, 5, 7, or any prime below 41, because n² − n + 41 has no solutions modulo those primes. With the most common divisors locked out, far more of the outputs are left to be prime. Why 41 works so well was traced in 1913 to a property of 163, which is 4 × 41 − 1, one of only nine numbers of its special kind.

193,939

A circular prime

Rotations
6, all prime
Shuffles
23 of 60 prime
Six-digit families
2
Catalogue
OEIS A016114

In one lineMove its first digit to the back, again and again: all six rotations are prime.

193,939 is prime. Take its first digit and move it to the back and you get 939,391, also prime. Do it again: 393,919, prime. Then 939,193, 391,939 and 919,393. All six turns of the number are prime, and the seventh brings you back to where you started.

Fig. 7 · Read from any starting point
1939396 rotations
start193,939prime
turn 1939,391prime
turn 2393,919prime
turn 3939,193prime
turn 4391,939prime
turn 5919,393prime
Start at the yellow 1 and read clockwise, then start one digit later. All six readings are prime.

A prime like this is called a circular prime: write its digits around a circle, start reading anywhere, and you always read a prime. The small ones are easy to spot. 13 and 31 are both prime, so are 197, 971 and 719. Six digits is where it gets rare, and 193,939 is one of only two six-digit families, the other being 199,933.

The word to be careful with is rotate. It is often said that any arrangement of 193,939’s digits is prime, and that is not true. Its digits can be shuffled into 60 different numbers, and 37 of them are composite: 139,993 is 7 × 19,999, and 193,399 is 37 × 5,227. Only the six rotations hold up.

The digits are no accident either. A circular prime with two or more digits can only use 1, 3, 7 and 9, because every digit takes a turn at the end of the number, and a number ending in an even digit or a 5 is never prime. Below a million there are just 19 circular families. Past that, searches have found nothing new except the repunits, numbers written only with 1s, like the 19-digit 1,111,111,111,111,111,111, which turn into themselves however you rotate them.

(p, p)

Primes drawn in polar coordinates

Spiral arms from
44 rad ≈ 7 turns
Rays from
710 rad ≈ 113 turns
Rays with primes
280 of 710
Theorem
Dirichlet, 1837

In one linePlot each prime at distance p and angle p: a swirl at 5,000 primes, 280 straight rays at 50,000.

Here is a way to draw the primes. For each prime p, walk p steps out from the centre of the page, at an angle of p radians, and put a dot there. 2 goes two steps out at an angle of 2 radians, 3 goes three steps out at 3 radians, and so on. Do it for the first 5,000 primes and you get a cloud with a swirl in the middle. Do it for the first 50,000 and the swirl is gone, replaced by straight rays bursting out from the centre.

Fig. 8 · Same rule, two zoom levels

First 5,000 primes

First 50,000 primes

Each prime p is a dot at distance p from the centre and angle p radians, drawn live in your browser.

It looks like a secret of the primes, but most of it comes from the radian. A full turn is 2π, about 6.283 radians, and some whole numbers of radians land very close to a whole number of turns. 44 radians is almost exactly 7 turns, so numbers 44 apart end up nearly on top of each other, drifting a little each time. That slow drift is what draws the spiral arms in the left picture.

Zoom out and a better fit takes over. 710 radians is 113 turns plus just 0.0006 of a radian, so numbers 710 apart line up along almost perfectly straight lines. That makes 710 possible rays. Primes cannot sit on most of them: a ray made of even numbers, or of multiples of 5 or 71, holds at most one prime. That leaves exactly 280 rays, and the primes are spread almost evenly across all 280. Those are the spokes on the right.

So the pattern is part approximation of π and part a real fact about primes. The rays exist for every whole number; what the primes add is the gaps, and the evenness. That evenness is Dirichlet’s theorem, proved in 1837: primes do not favour any of the rays they are allowed to sit on.

7 → 8

The only prime followed by a cube

Prime
7
Cube
8 = 2³
Key identity
x³ − 1 = (x − 1)(x² + x + 1)
Squares
Only 3 → 4

In one line7 sits right before 8 = 2³, and a one-line factorisation shows no other prime ever can.

7 is prime, and the very next number, 8, is a cube: 2 × 2 × 2. That sounds like a small coincidence, the kind you could find more of if you kept looking. You cannot. 7 is the only prime in the whole number line that sits right before a cube.

The proof fits on one line. A number one less than a cube is x³ − 1, and x³ − 1 always factors as (x − 1)(x² + x + 1). For that product to be prime, one of the two factors has to be 1. The second one, x² + x + 1, is never 1 for a positive x, so the first must be: x − 1 = 1, which means x = 2, the cube is 8 and the prime is 7. Every other cube has a composite number in front of it.

Fig. 9 · x³ − 1 = (x − 1)(x² + x + 1)
cubeone lessfactors
2³ = 871 × 7 · prime
3³ = 27262 × 13
4³ = 64633 × 21
5³ = 1251244 × 31
6³ = 2162155 × 43
7³ = 3433426 × 57
8³ = 5125117 × 73
One less than a cube always splits into two factors. Only at x = 2, where the first factor is 1, is the number left prime.

The same trick works from the other side. A number one more than a cube is x³ + 1 = (x + 1)(x² − x + 1), and that can only be prime when x² − x + 1 = 1, so x = 1 and the prime is 2. And squares behave the same way: one less than a square is x² − 1 = (x − 1)(x + 1), which is prime only for x = 2. So 3 is the only prime followed by a square, and 7 is the only one followed by a cube.

1,234,567,891

Primes that count upward

Shortest
10 digits
Next
20 and 28 digits
Strict rule, ≤ 1,000 digits
2 primes
Searched
Up to 1,000 digits

In one lineCount 1, 2, 3 … 9, wrap round, stop on a 1: at 10 and 28 digits the result is prime.

Write the digits in order, 1, 2, 3 and on to 9, then start again and stop on a 1. You get 1,234,567,891, and it is prime. Go round three times instead and stop on a 1 again: 1,234,567,891,234,567,891,234,567,891, a 28-digit number, is also prime. A third version runs the count through 0 once before coming back round, 12,345,678,901,234,567,891, and that is prime as well.

Fig. 10 · Count up, wrap round, stop on a 1
10 digits1234567891prime
20 digits12345678901234567891prime
28 digits1234567891234567891234567891prime
Each block is one count from 1 upward. The yellow 1 is where the number stops; the outlined 0 in the middle row is the one place the count runs through zero.

These three are often quoted as the only known primes of their kind. That claim depends on how tightly you state the rule, because the three numbers do not quite follow the same one. The first and third skip 0 and go straight from 9 back to 1. The middle one counts through 0 on its first lap and skips it on the second.

Take the strictest version: count 1 to 9, wrap straight back to 1, and stop on a 1. Those numbers have 10, 19, 28, 37 digits and so on, and their digits always add up to one more than a multiple of 45, so 3 never divides them. Even so, primes are scarce. A search of every such number up to 1,000 digits finds just two: the 10-digit and the 28-digit ones. Relax the rule and let the count stop on any digit, and a 70-digit prime appears that ends in …4567.

Count through 0 every time, 1234567890 over and over, and the first prime does not arrive until 171 digits. More follow at 277, 367, 561 and 567 digits. The larger numbers in this entry have passed standard probable-prime tests rather than a full certificate, which is normal at these sizes.

So it is a pattern with a moral, like the nines and zeros above. Change one word in how you describe the count and the list of “only known” examples changes with it.

Quick answersPrime number questions

Is every prime number one more or one less than a multiple of 6?

Yes, for every prime bigger than 3. Any whole number has the form 6k, 6k + 1, 6k + 2, 6k + 3, 6k + 4 or 6k + 5. The forms 6k, 6k + 2 and 6k + 4 are even and 6k + 3 is divisible by 3, so a prime above 3 must be 6k + 1 or 6k + 5, which is one more or one less than a multiple of 6.

Is every number of the form 6k ± 1 a prime number?

No. The rule only runs one way. 25 is one more than 24 and 35 is one less than 36, yet both are divisible by 5. Every prime after 3 has the form 6k ± 1, but many numbers of that form are composite.

Why is p² − 1 divisible by 24 for every prime p greater than 3?

Write the prime as 6k ± 1. Then p² − 1 = 36k² ± 12k = 12k(3k ± 1). One of k and 3k ± 1 is always even, so the product is a multiple of 24. For example 5² − 1 = 24, 7² − 1 = 48 and 11² − 1 = 120.

What is the largest right-truncatable prime?

73,939,133. Removing its last digit again and again gives 7,393,913, 739,391, 73,939, 7,393, 739, 73 and 7, all of them prime. There are exactly 83 right-truncatable primes and this is the largest.

What is a circular prime?

A prime that stays prime however you rotate its digits. 193,939 is one: 939,391, 393,919, 939,193, 391,939 and 919,393 are all prime. Rotating is not the same as shuffling; most rearrangements of 193,939's digits are composite.

Is there a formula that only gives prime numbers?

No polynomial with whole-number coefficients gives only primes. Euler's n² − n + 41 comes close at the start, giving primes for n = 1 to 40, but at n = 41 it gives 41². Even so, about 26% of its values for n up to a million are prime, more than six times the rate for random numbers of that size.

Is 7 the only prime that comes right before a cube?

Yes. One less than a cube is x³ − 1 = (x − 1)(x² + x + 1), which can only be prime when x − 1 = 1. That gives x = 2, the cube 8 and the prime 7.

Checked againstSources

  • OEIS A024770, Right-truncatable primes.
  • Chris K. Caldwell, The Prime Pages, “Truncatable prime” glossary entry.
  • OEIS A007310, Numbers congruent to 1 or 5 mod 6.
  • OEIS A232449, Belphegor numbers that are prime.
  • OEIS A005846, Primes of the form n² + n + 41.
  • OEIS A016114, Circular primes.
  • Grant Sanderson, 3Blue1Brown, “Why do prime numbers make these spirals?” (2019).

Beyond Euclid

Liked this? Get one like it every week.

One email a week, handpicked by Ali. 242 issues so far. Free to join.

As an Amazon Associate, Abakcus earns from qualifying purchases.