cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A134996 Dihedral calculator primes: p, p upside down, p in a mirror, p upside-down-and-in-a-mirror are all primes.

This page as a plain text file.
%I A134996 #39 Feb 16 2025 08:33:07
%S A134996 2,5,11,101,181,1181,1811,18181,108881,110881,118081,120121,121021,
%T A134996 121151,150151,151051,151121,180181,180811,181081,188011,188801,
%U A134996 1008001,1022201,1028011,1055501,1058011,1082801,1085801,1088081,1108201,1108501,1110881,1120121,1120211
%N A134996 Dihedral calculator primes: p, p upside down, p in a mirror, p upside-down-and-in-a-mirror are all primes.
%C A134996 The digits of a(n) are restricted to 0, 1, 2, 5, 8. - _Ivan N. Ianakiev_, Oct 08 2015
%C A134996 The first term containing all the possible digits is 108225151. There are 2958 such terms up to 10^12, the last one in this range being 188885250551. - _Giovanni Resta_, Oct 08 2015
%H A134996 Alois P. Heinz, <a href="/A134996/b134996.txt">Table of n, a(n) for n = 1..7174</a>
%H A134996 C. K. Caldwell, The Prime Glossary, <a href="https://t5k.org/glossary/page.php?sort=DihedralPrime">Dihedral Prime</a>
%H A134996 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/DihedralPrime.html">Dihedral Prime.</a>
%e A134996 120121 is such a number because 120121, 121021 (upside down), 151051 (mirror) and 150151 are all prime. (This is the smallest one in which all four numbers are distinct.)
%t A134996 lst1={2,5};
%t A134996 startQ[n_]:=First[IntegerDigits[n]]==1;
%t A134996 subQ[n_]:=Module[{lst={0,1,2,5,8}},SubsetQ[lst,Union[IntegerDigits[n]]]];
%t A134996 rev[n_]:=Reverse[IntegerDigits[n]];
%t A134996 updown[n_]:=FromDigits[rev[n]];
%t A134996 mirror[n_]:=FromDigits[rev[n]/.{2-> 5,5-> 2}];
%t A134996 updownmirror[n_]:=FromDigits[rev[mirror[n]]];
%t A134996 lst2=Select[Range@188801,And[startQ[#],subQ[#],PrimeQ[#],PrimeQ[updown[#]],PrimeQ[mirror[#]],PrimeQ[updownmirror[#]]]&];
%t A134996 Join[lst1,lst2] (* _Ivan N. Ianakiev_, Oct 08 2015 *)
%o A134996 (Python)
%o A134996 from sympy import isprime
%o A134996 from itertools import count, islice, product
%o A134996 def t(s): return s.translate({ord("2"):ord("5"), ord("5"):ord("2")})
%o A134996 def ok(s): # s is a string of digits
%o A134996     return all(isprime(int(w)) for w in [s, s[::-1], t(s), t(s[::-1])])
%o A134996 def agen(): # generator of terms
%o A134996     yield from (2, 5)
%o A134996     for d in count(2):
%o A134996         for mid in product("01258", repeat=d-2):
%o A134996             s = "1" + "".join(mid) + "1"
%o A134996             if ok(s): yield int(s)
%o A134996 print(list(islice(agen(), 35))) # _Michael S. Branicky_, Apr 27 2024
%Y A134996 Cf. A134997, A134998, A048661.
%K A134996 nonn,base,nice
%O A134996 1,1
%A A134996 _Mike Keith_
%E A134996 5 added by _Patrick Capelle_, Feb 06 2008