|
|
A119378
|
|
Palindromic composites such that some digit permutation is prime.
|
|
1
|
|
|
121, 232, 272, 292, 323, 343, 434, 494, 575, 616, 737, 767, 818, 838, 878, 949, 959, 979, 10201, 10801, 10901, 11011, 11611, 11711, 11911, 12121, 12221, 12521, 13031, 13231, 13531, 13631, 14041, 14141, 14641, 14941, 15151, 15251, 15751, 15851, 16261, 16861, 16961
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
LINKS
|
|
|
EXAMPLE
|
121 is composite that have a prime digit permutation: 211.
1001 is composite, but is not a term since 0011, though prime, contains leading zeros, which is not allowed here.
|
|
MATHEMATICA
|
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 *)
|
|
PROG
|
(Python)
from sympy import isprime
from itertools import count, islice, product
from sympy.utilities.iterables import multiset_permutations as mp
def pals(base=10): # generator for all palindromes as strings
digits = "".join(str(i) for i in range(base))
for d in count(1):
for p in product(digits, repeat=d//2):
if d//2 > 0 and p[0] == "0": continue
left = "".join(p); right = left[::-1]
for mid in [[""], digits][d%2]: yield left + mid + right
def ok(s): # where s is string of digits
if isprime(int(s)): return False
return any(p[0]!="0" and isprime(int("".join(p))) for p in mp(s))
def agen():
yield from (int(s) for s in pals() if ok(s))
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|