Dihedral Prime Calculator
Primes
- On a seven-segment calculator display only the digits 0, 1, 2, 5 and 8 survive being flipped; any other digit disqualifies the number at once.
- Build the four dihedral readings of 120,121: as written, upside down (digit order reversed), mirrored (2 and 5 swap and the order reverses), and mirrored in place.
- All four readings are prime, so the number is a dihedral prime - it stays prime however the calculator is turned or reflected.
- This is stricter than a strobogrammatic test: primality must survive all four readings, not just the upside-down one.
Write a number on a seven-segment calculator display and you can do things with it that paper does not allow: turn the display upside down, or hold it to a mirror. Most digits break - but 0, 1, 2, 5 and 8 survive, with 2 and 5 swapping places in the mirror. A dihedral prime is a prime built only from those digits whose four readings - as written, upside down, mirrored, and mirrored in place - are all prime at once.
This calculator forms the four readings exactly as the display model defines them and tests each one. The showcase example is 120121: its readings 120121, 121021, 151051 and 150151 are all prime. The cautionary example is 151: prime itself and a palindrome, but its mirrored reading is 121 = 11 x 11, so it fails.
Extending the search shows how restrictive the four-reading demand really is. Below 200,000 there are only 22 dihedral primes, and the largest of them is 188801. Six digits of freedom, a five-letter digit alphabet, and four simultaneous primality conditions leave just 22 survivors - the calculator's list mode up to 200,000 reproduces the complete census.
Worked examples
Is 120121 a dihedral prime?
(0 - test a single number · 120121)
| is 120,121 a dihedral prime? | Yes - all four calculator readings are prime |
| reading 1 - as written | 120,121 - prime |
| reading 2 - turned upside down | 121,021 - prime |
| reading 3 - mirrored, then read | 151,051 - prime |
| reading 4 - digits mirrored in place | 150,151 - prime |
Is 151 a dihedral prime?
(0 - test a single number · 151)
| is 151 a dihedral prime? | No - at least one of its four readings is composite |
| reading 1 - as written | 151 - prime |
| reading 2 - turned upside down | 151 - prime |
| reading 3 - mirrored, then read | 121 - composite |
| reading 4 - digits mirrored in place | 121 - composite |
Dihedral primes up to 2,000
(1 - list up to a limit · 2000)
| dihedral primes up to 2,000 | 2, 5, 11, 101, 181, 1,181, 1,811 |
| how many there are | 7 |
| largest of them | 1,811 |
| digits allowed | 0, 1, 2, 5, 8 only |
Primes that survive the calculator flip
The seven-segment model used here is strict. Only the digits 0, 1, 2, 5 and 8 have valid flipped readings; any number containing 3, 4, 6, 7 or 9 is disqualified before primality is even tested. Under a mirror, 2 and 5 exchange: a segment pattern that reads as 2 reflects into the pattern for 5, and vice versa. Turning the display upside down reverses the digit order.
Combining the two operations gives four readings: the number as written; the digit order reversed (upside down); the digits mirrored with 2 and 5 swapped and the order reversed (the true mirror image); and the digits mirrored in place. A dihedral prime must be prime in all four orientations - the dihedral group of the display, acting on the number, never leaves the primes.
The model's exclusions deserve one clarification, because other references differ. Some authors allow the digits 6 and 9 with the rotation swap familiar from strobogrammatic numbers. This calculator follows the stricter seven-segment convention in which the readings are formed from the segment patterns themselves: 6 and 9 do not produce valid flipped segment readings in the mirror, so they are excluded, and the digit set is exactly {0, 1, 2, 5, 8}. Whichever convention a table uses, it should state it - the membership of numbers like 120121 is the same here, but borderline candidates can differ between conventions.
- Allowed digits: 0, 1, 2, 5, 8 only
- Mirror swaps 2 and 5; upside-down reverses the digit order
- Four readings, all four must be prime
- Any 3, 4, 6, 7 or 9 disqualifies the number at once
Worked example: 120121
Take 120121, a six-digit candidate using only allowed digits. As written it is prime. Reversed, it reads 121021 - prime. Mirrored (swap 2 and 5, then reverse the order) it reads 151051 - prime. Mirrored in place it reads 150151 - prime. Four orientations, four primes: 120121 is a dihedral prime.
Now take 151. It passes the easy tests - it is prime, and it is a palindrome, so the first two readings agree. But mirroring swaps its 5 to a 2, producing 121, and 121 = 11 x 11 is composite. One bad reading is enough: 151 is not a dihedral prime. The mirror readings, not the upside-down one, are where most candidates die.
| Number | Reading 1 (as written) | Reading 2 (upside down) | Reading 3 (mirrored, then read) | Reading 4 (mirrored in place) | Verdict |
|---|---|---|---|---|---|
| 120121 | 120121 - prime | 121021 - prime | 151051 - prime | 150151 - prime | dihedral prime |
| 151 | 151 - prime | 151 - prime | 121 - composite | 121 - composite | not dihedral |
Why the family is so thin
Up to 2,000 there are only seven dihedral primes: 2, 5, 11, 101, 181, 1181 and 1811. Each additional digit tightens the trap in two ways at once - the digit itself must come from a five-symbol alphabet, and it participates in four different numbers that must simultaneously be prime. The readings are correlated but far from identical, so the survival probability drops steeply with length.
Compare the neighbouring families: palindromic primes below 2,000 number in the dozens, and strobogrammatic primes (upside-down only) are also more common. Requiring the mirror readings as well is what makes the dihedral family exceptionally sparse.
The thinness compounds in a specific way: the four readings of an n-digit candidate are four different n-digit numbers, and while they share digits, their primality is close to independent - so the survival chance falls off roughly like the fourth power of the prime density at that size, tempered by the digit restrictions. That is the arithmetic behind the census figures: 7 survivors below 2,000, and still only 22 below 200,000, in a range containing tens of thousands of primes.
- Dihedral primes up to 2,000: 2, 5, 11, 101, 181, 1181, 1811
- Each extra digit adds four simultaneous primality demands
- The mirror readings kill more candidates than the upside-down reading
Dihedral vs strobogrammatic primes
A strobogrammatic number only has to survive a 180-degree rotation, traditionally with the paper digits 0, 1, 6, 8, 9 where 6 and 9 swap. The dihedral test is a different, stricter game: it uses the seven-segment digit set {0, 1, 2, 5, 8}, where 6 and 9 do not appear at all, and it adds the two mirror readings on top of the rotation.
So the families overlap without containing each other. 181 is in both worlds; a number using 6 or 9 can be strobogrammatic but never dihedral in this model; and a number using 2 or 5 can be dihedral but is invisible to the strobogrammatic test. The calculator follows the seven-segment definition throughout - digits, swaps and readings.
Building dihedral primes digit by digit
Constructing a dihedral prime by hand teaches the constraints in order. The first and last digits come from {1, 2, 5, 8} in practice: a leading digit of 0 is impossible, and every reading ends in some digit of the original, so no reading can end in 0, 2 or 5 unless it is the prime 2 or 5 itself - an even or five-multiple ending kills that reading. This is why the multi-digit members start and end with 1 or 8: 101, 181, 1181, 1811 all obey the rule.
The interior digits then have to satisfy four primality conditions that share digits in different orders - a tightly coupled system. Change one interior digit and all four readings change. The 22 survivors below 200,000, ending at 188801, are the complete set of compromises the system allows at up to six digits.
A practical search therefore works digit-first: generate candidates from the allowed alphabet with legal end digits, form the four readings, and test the cheapest reading first - the mirrored one, empirically the most lethal. The calculator follows the same logic and reports all four readings with their verdicts, so a failure always shows which orientation broke.
The dihedral family also has a famous degenerate cousin: strobogrammatic primes, which survive only the 180-degree rotation and allow the digit pairs 6 and 9. The two families overlap on the digits {0, 1, 8} but diverge on 2, 5, 6 and 9, and their censuses differ accordingly. This page's convention - the seven-segment mirror-and-rotate model with digit set {0, 1, 2, 5, 8} - is the stricter and more commonly tabulated dihedral definition, and it is the one under which the census of 22 below 200,000 and the largest member 188801 are stated.
- Only 22 dihedral primes below 200,000; the largest is 188801
- Multi-digit members start and end with 1 or 8 - readings cannot end in 0, 2 or 5
- The mirrored reading is the most common point of failure
Calculator displays and the culture of flipped digits
The dihedral primes belong to a long calculator tradition. Generations of schoolchildren discovered that 0.7734 spells hELL upside down and that 58008 has its own joke; the seven-segment display quietly imposes a small alphabet on anyone who plays with it. The dihedral prime definition takes that folk alphabet seriously: digits {0, 1, 2, 5, 8}, the mirror swap 2 <-> 5, and primality demanded in every orientation.
What makes the concept more than a novelty is the coupling. A palindromic prime constrains a number against its own reversal; a dihedral prime constrains it against three other numbers that share its digits in scrambled orders and with 2s and 5s exchanged. The 22 examples below 200,000 are the complete list of truces between those competing demands at up to six digits.
If you experiment, start from the survivors: 181 and 1181 show how 1s and 8s - the digits unchanged by every flip - form the safe scaffolding, with a single 2 or 5 pair as the risky decoration. Most hand-made candidates fail exactly where 151 failed: in the mirror.
- The folk calculator alphabet {0, 1, 2, 5, 8} is the dihedral digit set
- Digits 1 and 8 are unchanged by every flip - the safe scaffolding
- Complete census below 200,000: 22 primes, largest 188801
FAQs
What is a dihedral prime?
A prime built only from the digits 0, 1, 2, 5 and 8 whose four seven-segment readings - as written, upside down, mirrored, and mirrored in place - are all prime. 120121 qualifies: its readings 120121, 121021, 151051 and 150151 are all prime.
Is 120121 a dihedral prime?
Yes. Its four readings are 120121, 121021, 151051 and 150151, and every one of them is prime.
Why can't a dihedral prime contain the digit 3?
In the seven-segment model only 0, 1, 2, 5 and 8 have valid flipped readings. A number containing 3, 4, 6, 7 or 9 cannot form all four readings, so it is disqualified before any primality test.
Is 151 a dihedral prime?
No. 151 is prime and a palindrome, but its mirrored reading is 121 = 11 x 11, which is composite. One composite reading is enough to fail the dihedral test.
How many dihedral primes are there up to 2,000?
Only 7: 2, 5, 11, 101, 181, 1181 and 1811. Each extra digit multiplies the readings that must simultaneously be prime, so the family grows very slowly.
What are the four readings of a dihedral prime?
The number as written; its digit order reversed (upside down); its digits mirrored - 2 and 5 swap - with the order reversed; and its digits mirrored in place. All four must be prime.