Two-Sided Prime Calculator
Primes
- Truncate 317 from the left one digit at a time: 317 -> 17 -> 7; every stage must stay prime.
- Truncate it from the right as well: 317 -> 31 -> 3; every stage must stay prime, down to a single digit.
- Both chains stay prime at every step, so the number is a two-sided prime - it is both left-truncatable and right-truncatable.
- The whole family has just 15 members and the largest is 739,397, so two-sided primes are far rarer than either one-sided kind.
Take a prime and start deleting digits from the left: if every stage stays prime down to a single digit, it is left-truncatable. Do the same from the right for right-truncatable. A two-sided prime survives both directions at once - and that double demand is so severe that the entire family, in all of mathematics, has 15 members. The largest is 739,397, and there are provably no more.
This calculator walks both chains for your number and shows every stage, so a failure is always located: you can see the exact truncation that broke. The model example is 317, whose left chain runs 317 -> 17 -> 7 and whose right chain runs 317 -> 31 -> 3, prime at every step. The instructive failure is 11: truncating either way reaches 1, which is not prime, so 11 is not two-sided despite looking like the perfect candidate.
In list mode the calculator prints the family up to your limit - up to 1,000 you get all twelve of the small members, from 2 to 797. The finiteness is the headline: unlike most prime families on this site, this one's complete census is known, and it fits in one line.
Worked examples
Is 317 a two-sided prime?
(0 - test a single number · 317)
| is 317 a two-sided prime? | Yes - prime under truncation from both ends |
| left truncation chain | 317 -> 17 -> 7 |
| right truncation chain | 317 -> 31 -> 3 |
| largest two-sided prime of all | 739,397 - the family is finite |
Is 11 a two-sided prime?
(0 - test a single number · 11)
| is 11 a two-sided prime? | No - some truncation is not prime, or it contains a 0 |
| left truncation chain | 11 -> 1 |
| right truncation chain | 11 -> 1 |
| largest two-sided prime of all | 739,397 - the family is finite |
Two-sided primes up to 1,000
(1 - list up to a limit · 1000)
| two-sided primes up to 1,000 | 2, 3, 5, 7, 23, 37, 53, 73, 313, 317, 373, 797 |
| how many there are | 12 |
| largest of them | 797 |
| largest that exists at all | 739,397 - only 15 exist |
Prime from both ends
The two chains of 317 show the definition at work. From the left: 317, delete the 3 to get 17, delete the 1 to get 7 - prime, prime, prime. From the right: 317, delete the 7 to get 31, delete the 1 to get 3 - prime, prime, prime. Both chains end at a prime single digit, and every intermediate stage is prime. That is the complete test, and 317 passes it.
The single-digit endpoint is where intuition fails most often. The final digit reached from the left is the number's last digit; from the right, its first digit. Both must be prime digits - 2, 3, 5 or 7. A chain that reaches 1 or 9 has failed at the last step, however prime everything before it was. The calculator's chains display the endpoint explicitly so this is never ambiguous.
- 317: left chain 317 -> 17 -> 7, right chain 317 -> 31 -> 3 - all prime
- Both chains must end at a prime digit: 2, 3, 5 or 7
- A 0 digit anywhere breaks the chains and disqualifies the number
- Family total: 15 numbers, largest 739,397
Why 11, 13, 17, 31, 71 and 79 fail
The most common misconception about two-sided primes concerns the small two-digit primes. 11, 13, 17, 31, 71 and 79 all look truncatable - each is prime, and deleting one digit leaves a single digit. But that digit is 1 in every one of these cases from at least one side: 13 truncates from the right to 1, 31 from the left to 1, 11 from both sides to 1. Since 1 is not prime, all six fail. The genuine two-digit members are only 23, 37, 53 and 73, whose chains end at 2, 3, 5 or 7.
The same trap scales up: a long candidate can have a fully prime chain except for a final 1, and it fails outright. There is no partial credit in the definition - which is precisely why the family collapses to 15. The calculator's failure message names the cause: a composite truncation, a chain reaching 1, or a 0 digit.
- 11, 13, 17, 31, 71, 79 all fail: a chain reaches the non-prime 1
- The genuine two-digit members: 23, 37, 53, 73
- Below 100 the full family is 2, 3, 5, 7, 23, 37, 53, 73 - eight numbers
The complete family of 15
Here is the census. Single digits: 2, 3, 5, 7. Two digits: 23, 37, 53, 73. Three digits: 313, 317, 373, 797. Then 3137, 3797, and finally 739397 - written 739,397. Fifteen numbers, and the list is not 'known so far' but complete: the truncation tree can be grown digit by digit from the single-digit primes, every branch dies, and the full search has been carried out. No 7-digit or longer two-sided prime exists.
Finiteness puts two-sided primes in rare company among prime families. Twin primes, palindromic primes, Pierpont primes - all are conjectured infinite. The two-sided family is a closed book: the calculator's list mode with a large limit reproduces the entire family and then stops, correctly, forever.
| Digits | Two-sided primes | Count |
|---|---|---|
| 1 | 2, 3, 5, 7 | 4 |
| 2 | 23, 37, 53, 73 | 4 |
| 3 | 313, 317, 373, 797 | 4 |
| 4 | 3137, 3797 | 2 |
| 6 | 739397 | 1 |
| 5 or 7+ | none | 0 |
Two-sided vs one-sided truncatable primes
The sibling pages cover the one-sided families, and their sizes make the contrast vivid. Right-truncatable primes, which must survive deletion from the right only, number 83 in total - also finite, but five times the two-sided census, with a largest member of 24 digits. Left-truncatable primes (with no zero digits allowed) number 4,260. Requiring both chains at once intersects the two trees and leaves just 15 numbers standing.
The intersection logic is visible in the members: every two-sided prime is automatically a member of both one-sided families, and the calculator's chains are exactly the two one-sided tests run together. If you want to explore the neighbourhood, run the same candidate - say 3797 - through all three pages and watch it pass everywhere, then try 739397's near relations and watch the two-sided door close.
How a finite census gets proved
Finiteness here is not an observation but a construction. Start from the four prime digits 2, 3, 5, 7 and grow candidates by adding a digit on the right, keeping only the extensions that stay prime. The tree of right-truncatable primes branches at first - 23, 37, 53, 73 appear at length two - but every branch eventually dies, and the complete tree has 83 members, the longest just 8 digits (73939133). The leftward tree, with the convention that no stage may contain a 0 digit, is bushier: 4,260 members, the longest reaching 24 digits. Both trees are finite because at each length only digits from a shrinking allowed set can extend a survivor, and the survivors thin out faster than the digits multiply.
A two-sided prime must sit in both trees at once, with the same digit string. Intersecting the two finite censuses - or equivalently growing candidates that survive truncation from both ends - leaves the 15 numbers listed on this page. The proof of completeness is the exhaustion of the trees: there is no 16th member hiding at some untested length, because the trees themselves terminate. The six-digit 739,397 is not merely the largest found; it is the largest there is.
That is a genuinely unusual situation in prime hunting, and it is why this family makes such a satisfying calculator page: the list mode does not show 'the first few' of an endless sequence - it shows the whole of mathematics' supply.
Digit games usually live in base 10 by convention, and this family is no exception - but the convention is worth noticing, because truncatability is a property of the representation, not of the number itself. 317 is two-sided in decimal; in binary its representation is a different string with different truncation behaviour. The calculator works in base 10, as do the standard tables: the census of 15, the largest member 739,397, and the chain displays are all decimal statements.
- Right-truncatable tree: 83 members, longest 24 digits, every branch dies
- Left-truncatable tree (no zero digits): 4,260 members
- Two-sided = the intersection: 15 numbers, proved complete
Neighbours that fail: reading the chains
The near-misses teach the definition better than the members do. Take 3137, a member: left chain 3137 -> 137 -> 37 -> 7 (137 prime, 37 prime, 7 prime), right chain 3137 -> 313 -> 31 -> 3 (all prime). Now take 3797, also a member: left 3797 -> 797 -> 97 -> 7, right 3797 -> 379 -> 37 -> 3. And take 197, which is prime and truncates beautifully from the left - 197 -> 97 -> 7, all prime - but from the right its chain runs 197 -> 19 -> 1, dying at the non-prime 1: left-truncatable, not two-sided. The calculator prints these chains for any input, and the stage at which a chain dies is the informative part.
The largest member rewards the same exercise: 739397 truncates left through 39397, 9397, 397, 97, 7 and right through 73939, 7393, 739, 73, 7 - eleven prime stages in all, each one a small miracle of survival, and jointly the reason the family ends there: extending any of these chains by another digit, in either direction, has been checked and always fails.
- 3137: left chain via 137, 37, 7; right chain via 313, 31, 3 - all prime
- 739397 survives eleven truncation stages across both chains
- Every one-digit extension of every survivor has been checked - the tree is exhausted
FAQs
What is a two-sided prime?
A prime that stays prime as digits are deleted one at a time from the left and from the right, down to a single prime digit. 317 qualifies: its chains are 317 -> 17 -> 7 and 317 -> 31 -> 3.
How many two-sided primes exist?
Only 15 in total. The family is finite and completely known - the largest member is 739,397, and no longer example exists.
Is 11 a two-sided prime?
No. Truncating 11 from either side leaves 1, which is not prime, so the chain fails at the last step. The same trap catches 13, 17, 31, 71 and 79.
What are the two-sided primes below 100?
Only eight: 2, 3, 5, 7, 23, 37, 53 and 73. Primes like 13 and 31 fail because a truncation reaches 1.
What is the largest two-sided prime?
739,397. The truncation tree has been grown to exhaustion - every branch dies - so no larger two-sided prime exists.
Can a two-sided prime contain the digit 0?
No. A 0 digit breaks the chains - a truncation would produce a stage with a leading zero or an even ending - so the calculator rejects any candidate containing 0.