%I #42 Apr 09 2024 05:07:41
%S 11,101,181,16661,18181,19991,1008001,1160611,1180811,1190911,1688861,
%T 1880881,1881881,1988891,100111001,100888001,101616101,101919101,
%U 106111601,106191601,108101801,109111901,109161901,110111011,111010111,111181111,116010611,116696611
%N Palindromic prime numbers that consist only of the digits {0,1,6,8,9} and which remain palindromic primes when their digits are rotated by 180 degrees.
%C 10886968801 is the least palindromic prime of this sequence for which the set of digits is {0,1,6,8,9}.
%C Terms must start and end with digit 1 and be of odd length for n > 1. - _Michael S. Branicky_, Feb 19 2024
%H Michael S. Branicky, <a href="/A370447/b370447.txt">Table of n, a(n) for n = 1..16934</a> (all terms < 10^20)
%H Carlos Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_1163.htm">Puzzle 1163. Palindromic primes that are semiprimes when turned upside down</a>, The Prime Puzzles & Problems Connection.
%e 16661 becomes 19991 under such a rotation, and both are palindromic primes.
%o (PARI) rot(u)=my(v=[]);for(i=1,#u,my(x=u[i]);if(x==6,v=concat(9,v),x==9,v=concat(6,v),vecsearch([0,1,8],x)>0,v=concat(x,v)));v
%o is(x)=my(u=digits(x),su=Set(u));if(setintersect(su,Set([0,1,6,8,9]))!=su||!isprime(x)||Vecrev(u)!=u,return(0));my(y=fromdigits(rot(u)));return(isprime(y))
%o (Python)
%o from sympy import isprime
%o from itertools import product, count, islice
%o def flip180(s): return s[::-1].translate({54:57, 57:54})
%o def agen(): # generator of terms
%o yield 11
%o for digits in count(3, 2):
%o for rest in product("01689", repeat=digits//2-1):
%o for mid in "01689":
%o s = "".join(("1",)+rest+(mid,)+rest[::-1]+("1",))
%o if isprime(t:=int(s)) and isprime(int(flip180(s))):
%o yield t
%o print(list(islice(agen(), 28))) # _Michael S. Branicky_, Feb 19 2024
%Y Subsequence of palindromes in A007597.
%Y Cf. A002385, A178316.
%K nonn,base
%O 1,1
%A _Jean-Marc Rebert_, Feb 18 2024