ExplorationsRearrange the digits and ask again
Primes That Survive Every Shuffle
A primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. is a whole number greater than 1 divisible only by 1 and itself. Rearrange all the digits of a prime and ask whether every ordering is still prime: 13 passes because 31 is prime too, while 19 fails because 91 = 7 × 13. This page checks those rearrangements and explains which digits can survive.
Current view: The shuffle
Every distinct arrangement of one number’s digits, each marked prime or composite.
- 1
- 3
- 13prime
- 31prime
Nothing here failed, so 13 is a permutable prime. That is a complete statement about this one number: every arrangement of its digits was written out and every one of them was tested.
Every arrangement of these digits
| Arrangement | The number | Prime | Working |
|---|---|---|---|
| 1 | 13 | yes | prime |
| 2 | 31 | yes | prime |
- a digit tile
- one digit of the number, which every arrangement uses exactly once
- an arrangement
- one distinct ordering of those digits, tested for primality on its own
- the first failure
- the smallest arrangement that turned out composite, which ends the whole number
The digits stand as tiles at the top, and beneath them is one row per distinct arrangement, in ascending order, the number itself among them. Each row says whether that arrangement is prime, and the first composite row is outlined, because that single row is what ends the question for the whole number. Repeated digits are arranged once rather than once per position: 199 has three arrangements and not six, since swapping the two nines rewrites nothing.
13 survives every shuffle: all 2 arrangements of its digits are prime.
- Digits
- 2
- Arrangements
- 2
- Verdict
- survives
The number
Choose from twenty examples below, or enter your own number. Each choice opens all its arrangements; Run or Step then lets you check them in order.
Both 13 and 31 are prime, so every arrangement passes.
Step by step
Use Step for one change you can inspect, or Run to watch the changes accumulate.
Cases worth seeing
Try this
Before opening the survivors view, write down which digits you think a permutable prime of four digits could use. Then check the list, and see whether your reason was about the units place or about something else.
What is going on
Each explanation begins with a worked example and follows the same operation through intuition, formal statements and proofs. Later sections distinguish what is established from questions that remain open, so you can follow the level of detail useful to you.
- 131 313 is primethe number itself, which is one of its own arrangements
- 133 131 is primethe only other arrangement, so 13 survives every shuffle there is
- 191 919 is primeas primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. as 13, and just as much a starting point
- 199 191 = 7 × 13compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself., and one composite arrangement is enough to end the whole number
The laboratory does exactly that, one row per arrangement, and outlines the first row that comes back compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself.. Then it does it to every number below a bound at once and prints whatever survived, which turns out to be a very short list written in a very small alphabet.
Above one digit, every permutable primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. is written with nothing but 1, 3, 7 and 9. That is not something the search noticed. It is a theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results., and the argument for it is one sentence about the units place.
What you are seeing
A plain description of the process
Take a number, write its digits in every possible order, and ask whether every one of those arrangements is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself..
For 13, the two arrangements are 13 and 31, and both are primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.. Since nothing else can be made from a 1 and a 3, every arrangement passes the test, making 13 a permutable prime.
For 19 it is also two questions, and the second one ends it. Nineteen is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., and 91 is 7 × 13. One compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself. arrangement is enough, so 19 is out despite being prime itself.
The number is always one of its own arrangements, which is why the laboratory lists it rather than starting after it. A number that is not primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. fails at its own row, although a smaller compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself. arrangement may appear earlier because the list is sorted by value. The property being tested is about the whole set of arrangements, and the starting number belongs to that set.
Repeated digits are arranged once, not once per position. The digits of 199 give 199, 919 and 991, which is three arrangements rather than six, because swapping the two nines produces the same row of digits and counting it twice would be counting the same check twice.
The example chooser groups twenty starting values by what they demonstrate. Compare 113 with 131 to see that a different starting order gives the same arrangements, or compare 11 with 111 to see why having only one arrangement does not guarantee a primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.. For a larger case, 123456 has 720 arrangements, all divisible by 3 because their digits always add to 21. In The survivors view, selecting any listed number takes you back to The shuffle to inspect its arrangements.
Why it starts to make sense
Intuition, before any algebra
Run the search a little way and something odd happens to the alphabet. The survivors stop using most of the digits.
There is a reason, and it is worth finding before reading it. Take any number with two or more digits and pick a digit inside it. There is some rearrangement that puts that digit last. If the digit is 0, 2, 4, 6 or 8, the rearrangement is an even number of at least two digits, so it is compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself.. If the digit is 5, the rearrangement ends in 5 and is a multiple of five, so it is composite again.
So a number containing any of those six digits has an arrangement that is compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself., and it cannot survive. What is left is 1, 3, 7 and 9. Four digits out of ten, and no computation was involved.
This is the moment the page is really about. The search has been finding things, and it looked as though the alphabet was one of its findings, and it was not: the alphabet is a theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results. that would be true if nobody had ever run the search at all. The search confirms it over a range, the way a thermometer confirms that water boils. It is not where the fact comes from.
And having the right digits is not enough. 197 and 199 are both three digits from that alphabet, and 197 fails at 791 = 7 × 113 while 199 survives. Whatever separates them is not something the digits announce.
The key idea
Two facts, established two different ways
The sentence worth carrying away is this one.
A search over a range can confirm a theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results., and cannot produce one.
This page does both kinds of work and the difference is visible in the figures.
- Every permutable primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. with more than one digit uses only 1, 3, 7 and 9. Proved, by the argument above, for every number there is.
- There are exactly twenty-two permutable primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. below a million. Exhaustively checked over exactly that range, and it is a fact about that range.
The second one is the tempting one, because the list has such an obvious shape: nothing with four digits, nothing with five, nothing with six. It looks finished. The temptation is to read the empty rows as saying there are no more, and the search cannot say that, because the search stopped.
The repunitsDefinition: A repunit is a number written as a string of repeated one digits in a chosen base. are where that goes wrong in the most direct way available. Nineteen ones in a row is a prime numberDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.. Every arrangement of nineteen ones is the same nineteen ones, so it is trivially a permutable prime, and it sits about twelve orders of magnitude above the largest bound this laboratory offers. The search that found twenty-two numbers had no chance of seeing it and no opinion about it.
There is a theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results. here too, and it is somebody else's: a permutable primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. with more than three digits and fewer than digits must be a repunitDefinition: A repunit is a number written as a string of repeated one digits in a chosen base.. Slinko reports the bound with attribution to Richert; this page does not reproduce the calculation. Both ends of that range are part of the statement. It does not say that every large permutable prime is a repunit; it says that every permutable prime in one enormous but bounded band of digit lengths is, and above the band the question is simply not addressed. With that theorem the empty rows stop being an absence and become an explanation. Without it they are just where the computer stopped.
Formal statement
Precisely what is being claimed
Write in base tenDefinition: Decimal notation writes numbers in base ten, using digits 0 through 9 and place values based on powers of ten. with digits , and let be the set of values of all distinct arrangements of those digits, among them. Call permutable when every element of is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself..
- is permutable, since and both are primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.. Proved.
- is not, since . Proved.
- is not, since , while is, since and all three are primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.. Proved.
- If is permutable and , then every . Proved, below.
- The permutable primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. below are exactly Exhaustively checked over exactly that range.
- If is permutable and , then . Proved in the cited literature (Richert, as reported by Slinko), not reproduced here. The upper bound on is the theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results.'s own; nothing here covers a permutable primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. wider than that.
- , , , and are primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., and whether infinitely many are prime is open.
Statement 4 is what the page can prove for itself. Statement 5 is what it can check. Statement 7 is where both of them run out, and 6 is the bridge between them that belongs to somebody else.
Proof
Of the parts that admit one
Thirteen survives and nineteen does not. ; both are primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., and the list is complete because two digits admit two arrangements. and . ∎
The alphabet is . Let be permutable with digits, and suppose some digit of lies in . Choose the arrangement that places in the units position and any other digit in the leading position; such an arrangement exists because . Then , since it has digits and a non-zero leading digit, which is available because is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. and so not every digit of is zero.
If is even then , and if then . Either way has a divisorDefinition: A divisor of n is an integer that divides n with no remainder. strictly between and , so is compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself.. But and is permutable, so is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., a contradiction. Hence every digit of lies in . ∎
Note what that argument does not use: no bound, no search, no primality test on anything. It is a statement about every number with two or more digits, produced by moving one digit.
Twenty-two below a million. Sieve to ; discard every primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. containing a zero, by the argument above; group the rest by their digits sorted into order, so that one permutationDefinition: A permutation is an arrangement of items where order matters. class is one group; and declare a class permutable exactly when the group holds every arrangement the class has. Since is a power of ten, every arrangement of a -digit number is a -digit number and therefore inside the sieved range, so no class is decided on partial information. Counting the survivors gives the list in statement 5, in exact integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. arithmetic. This proves statement 5 and nothing else. ∎
What is not proved here. Statement 6, which is cited, and statement 7, which is open. It is worth being explicit about why extending the search would not help with either. Every additional number checked removes one candidate from an infinite supply, and the four-digit rows were already empty at the bound the page reaches. A proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. would have to be an argument about all , and the one that exists for statement 6 is not reproduced here.
Limits and frontier
Where this page stops being able to help
What this laboratory computes. Every arrangement of any number you type, up to eight digits, which is forty thousand arrangements at the ceiling and is refused above it rather than started. The survivors view sieves to the chosen bound, the largest being a million, and settles each permutationDefinition: A permutation is an arrangement of items where order matters. class by counting rather than by testing every arrangement separately. All of it is exact integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. arithmetic, and the test suite checks the result against a second implementation that shares none of the machinery: every arrangement of every primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. below a hundred thousand, generated as strings and tested one at a time.
What the repunitDefinition: A repunit is a number written as a string of repeated one digits in a chosen base. view does not do. It does not test or for primality, and it does not show every known repunit primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.. Those two are cited from the catalogue of known repunit primes, and the figure draws the first five of them: and several beyond it are also known or established as probable primes, and are past what this page will build. and are checked in the test suite by a probable-prime test with fixed bases, which settles outright and is strong evidence rather than a proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. for . The bars in the figure are drawn at the numbers' real lengths and their digits are not printed, because a thousand and thirty-one characters is not something a figure can show a reader.
Change the base and the subject changes. In base twoDefinition: Binary is a way to write numbers using only 0 and 1, with place values that double to the left. the only numbers with no zero digit are the repunitsDefinition: A repunit is a number written as a string of repeated one digits in a chosen base., so the permutable primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. in base two are exactly the Mersenne primes, and the alphabet argument becomes trivial rather than interesting. That is the clearest sign that this is a property of how a number is written and not of the number: 31 is a permutable prime in base tenDefinition: Decimal notation writes numbers in base ten, using digits 0 through 9 and place values based on powers of ten. and in base two, and 37 is one in base ten and not in base two, and 31 and 37 have not changed.
Where the mathematics is still moving. Whether there are infinitely many repunitDefinition: A repunit is a number written as a string of repeated one digits in a chosen base. primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. is open, and with the cited theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results. in hand that is the same question as whether the list of permutable primes ends over the band of digit lengths the theorem covers. Repunit primes are known at 2, 19, 23, 317 and 1031 digits, and further ones at 49081, 86453, 109297 and 270343 digits are known or established as probable primes; the search has gone a long way past that without settling whether the list ends, which is a search result and settles nothing.
Read this next to Every Even Number, Two Primes. That page has a search that never fails and this one has a search that almost always does, and both end in the same place: a finite range checked completely, and a statement about all numbers that the checking cannot touch.
What is actually established
Every statement on this page, with its status, its exact scope, and the date that status was last checked.
13 survives every shuffle: 13 and 31 are the only arrangements, and both are prime.
- Scope
- The single number 13, over both of its arrangements.
- Why
- Two arrangements and two primality checks, all on numbers below forty. Exhibiting the whole list is the proof, and there is no bound anywhere in it. This is the smallest case that has anything in it at all, since a single-digit prime has only one arrangement and survives for no reason worth stating.
- Status checked
19 is prime and does not survive: 91 is 7 × 13.
- Scope
- The single number 19, over both of its arrangements.
- Why
- One multiplication settles it. The point of putting this beside 13 is that both numbers are prime, so primality is not what the shuffle is testing: it is testing every arrangement at once, and one composite among them is enough.
- Status checked
197 is prime and does not survive, because 791 is 7 × 113, while 199 survives all three of its arrangements.
- Scope
- The two numbers 197 and 199, over all of their arrangements.
- Why
- Six arrangements for 197, of which 791 and 917 are composite, and three for 199, all prime. Both numbers are written with digits from {1, 3, 7, 9}, which is the whole reason the pair is on the page: the alphabet result rules numbers out and never rules one in, and a reader who has just been shown the alphabet argument is exactly the reader likely to forget that.
- Status checked
There are exactly twenty-two permutable primes below 1,000,000: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 199, 311, 337, 373, 733, 919 and 991.
- Scope
- Every integer from 2 to 999,999. Each was tested against all of its digit arrangements, so the list is complete for that range and covers nothing above it. In particular it says nothing about R19, which is a permutable prime with nineteen digits.
- Why
- A complete check of a finite range, which is a proof about that range and about nothing else. Notice what the list contains: nothing with four digits, nothing with five, nothing with six. That is a striking absence and it is still an absence over one range rather than a theorem, and the repunits are the standing reminder of the difference.
- Computation (exact)
- Every integer below 1,000,000, with the primes found by a sieve of Eratosthenes over the same range and each permutation class settled by comparing how many of its arrangements are prime against how many arrangements it has, in exact integer arithmetic throughout. The test suite checks the result against a second implementation that shares none of this machinery: every arrangement of every prime below 100,000, generated as strings and tested one at a time by trial division, with no sieving and no grouping. Recomputed in the test suite. Algorithm permutable-primes-1.
- Status checked
Every permutable prime with more than one digit is written using only the digits 1, 3, 7 and 9.
- Scope
- All base-ten numbers with two or more digits. This is a general theorem, not a fact about the range searched here, and the proof is three lines long.
- Why
- Suppose a permutable prime has more than one digit and contains a 0, 2, 4, 5, 6 or 8. Rotate that digit into the units place. The arrangement that results has at least two digits, so it is at least ten, and it is divisible by 2 or by 5 according to which digit was moved. A number larger than 5 and divisible by 2 or 5 is composite, so that arrangement is composite and the original number does not survive. Nothing is left but 1, 3, 7 and 9. The survivors view checks this over its own range and finds it holding, which is a confirmation of a theorem rather than a reason to believe it.
- Status checked
A permutable prime with more than three digits and fewer than 6 × 10^175 digits must be a repunit, a number written as nothing but ones.
- Scope
- Base ten, within the stated digit range. Slinko reports this bound with attribution to Richert. The underlying large calculation is not reproduced here.
- Why
- The search below a million checks four-, five- and six-digit candidates, not the enormous range covered by the cited result. The result does not settle digit lengths beyond its upper bound.
- Status checked
- Sources
- Absolute Primes
Whether there are infinitely many repunit primes is an open problem.
- Scope
- All repunits. Repunit primes are known at 2, 19, 23, 317 and 1031 digits, and further ones at 49081, 86453, 109297 and 270343 digits are known or established as probable primes; whether the list ends is not known.
- Why
- The two results above meet here and stop. If a permutable prime with more than three digits and fewer than 6 × 10^175 of them must be a repunit, then the question of how many permutable primes there are, over that band of widths, becomes the question of how many repunit primes there are, and nobody knows. R19 and R23 are checked in this page’s test suite by a probable-prime test; R317 and R1031 are cited. The list does not stop there: R49081, R86453, R109297 and R270343 are known or established as probable primes, and this page draws none of them. This laboratory can draw the first five and settle none of them, which is the honest end of a page that began with a shuffle anyone can do by hand.
- Status checked
Sources
Review notes show which bibliographic details Mathomaly has checked and which remain unresolved. Checking a publication record does not independently verify its proof.
A contribution on absolute primes. The previously listed journal was incorrect. The much larger digit bound discussed on this page is reported by Slinko and attributed there to Richert, not Johnson.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
Corrected the journal and pages, corroborated by reference 7 in Slinko's author preprint.
- OEIS A003459: absolute primes, every permutation of whose digits is prime, The On-Line Encyclopedia of Integer Sequences. Link
The catalogue of permutable primes. Referenced as somewhere to check this page against rather than as the source of anything printed here: the twenty-two below a million are recomputed by the kernel and cross-checked in the test suite against a brute force that shares none of its machinery.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
Checked the sequence identifier, definition and displayed initial terms on the database entry.
- OEIS A004022: primes of the form (10^k − 1)/9, the repunit primes, The On-Line Encyclopedia of Integer Sequences. Link
The known repunit primes. The five shortest are R2, R19, R23, R317 and R1031, and they are the five this page draws; R49081, R86453, R109297 and R270343 are known or established as probable primes and are not drawn. Cited for everything past R23, which this page draws by length or names in words and does not test: the primality of a thousand-digit number is not something a browser settles while a reader waits.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
Checked the sequence identifier, definition and displayed initial terms on the database entry.
Where the repunit question is kept as an open problem: whether infinitely many repunits are prime is not known, and neither is whether the list of permutable primes ends. Cited for the status of the question rather than for any number on this page.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
Publisher confirms the author, third edition and 2004 print publication. This check does not verify every section attribution.
Theorem 2 restricts the digit count of a non-repunit absolute prime beyond three digits to a multiple of 11088. The subsequent discussion reports Richert's larger 6 × 10^175 bound; the laboratory does not reproduce that calculation.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
Checked the author's preprint, Theorem 2, the following Richert attribution and bibliography. The upload date is 2018; no original journal date is inferred.
Related by mechanism
Connected by how they work, not by sharing a topic label.