login
Number of n-digit dihedral primes for which the 4 numbers (n, n upside-down, n in a mirror, n upside-down and mirrored) are distinct.
1

%I #16 Apr 28 2024 11:31:57

%S 0,0,0,0,0,4,12,16,132,308,1096,3704,12984,47008,179660,681608

%N Number of n-digit dihedral primes for which the 4 numbers (n, n upside-down, n in a mirror, n upside-down and mirrored) are distinct.

%H Carlos Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_039.htm">Puzzle 39. The Mirrorable Numbers (By Mike Keith)</a>, The Prime Puzzles and Problems Connection.

%o (Python)

%o from sympy import isprime

%o from itertools import count, islice, product

%o def t(s): return s.translate({ord("2"):ord("5"), ord("5"):ord("2")})

%o def a(n):

%o if n < 2: return 0

%o c = 0

%o for mid in product("01258", repeat=n-2):

%o s = "1" + "".join(mid) + "1"

%o ss = set([s, s[::-1], t(s), t(s[::-1])])

%o if len(ss) != 4: continue

%o if all(isprime(int(w)) for w in ss): c += 1

%o return c

%o print([a(n) for n in range(1, 11)]) # _Michael S. Branicky_, Apr 27 2024

%Y Cf. A134996.

%K base,more,nonn

%O 1,6

%A _Felice Russo_

%E a(11)-a(14) from _Sean A. Irvine_, Jun 25 2021

%E a(15)-a(16) from _Michael S. Branicky_, Apr 27 2024