Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #12 Nov 28 2022 01:47:24
%S 121,232,272,292,323,343,434,494,575,616,737,767,818,838,878,949,959,
%T 979,10201,10801,10901,11011,11611,11711,11911,12121,12221,12521,
%U 13031,13231,13531,13631,14041,14141,14641,14941,15151,15251,15751,15851,16261,16861,16961
%N Palindromic composites such that some digit permutation is prime.
%H Michael S. Branicky, <a href="/A119378/b119378.txt">Table of n, a(n) for n = 1..10000</a>
%e 121 is composite that have a prime digit permutation: 211.
%e 1001 is composite, but is not a term since 0011, though prime, contains leading zeros, which is not allowed here.
%t palQ[n_Integer, base_Integer] := Module[{idn = IntegerDigits[n, base]}, idn == Reverse@idn]; fQ[n_] := Union[PrimeQ /@ FromDigits /@ Permutations@ IntegerDigits@n][[ -1]] == True; Select[Range@15850, !PrimeQ@# && palQ[ #, 10] && fQ@# &] (* _Robert G. Wilson v_, Aug 04 2006 *)
%o (Python)
%o from sympy import isprime
%o from itertools import count, islice, product
%o from sympy.utilities.iterables import multiset_permutations as mp
%o def pals(base=10): # generator for all palindromes as strings
%o digits = "".join(str(i) for i in range(base))
%o for d in count(1):
%o for p in product(digits, repeat=d//2):
%o if d//2 > 0 and p[0] == "0": continue
%o left = "".join(p); right = left[::-1]
%o for mid in [[""], digits][d%2]: yield left + mid + right
%o def ok(s): # where s is string of digits
%o if isprime(int(s)): return False
%o return any(p[0]!="0" and isprime(int("".join(p))) for p in mp(s))
%o def agen():
%o yield from (int(s) for s in pals() if ok(s))
%o print(list(islice(agen(), 43))) # _Michael S. Branicky_, Nov 27 2022
%K base,nonn
%O 1,1
%A _Tanya Khovanova_, Jul 24 2006
%E More terms from _Joshua Zucker_ and _Robert G. Wilson v_, Aug 04 2006
%E a(41) and beyond from _Michael S. Branicky_, Nov 27 2022