login
A271438
Numbers n such that the number formed by concatenating in ascending order the first n multidigit palindromic primes is prime.
0
OFFSET
1,2
LINKS
G. L. Honaker, Jr. and C. Caldwell, 11101...10301 (52-digits), Prime Curios!.
EXAMPLE
Concatenating in ascending order the 17 smallest palindromic primes with at least two digits gives 1110113115118119131335337338372775778779791992910301, which is prime, so 17 is a term of the sequence.
PROG
(PARI) nextpalprime(n) = my(p=nextprime(n)); while(p!=eval(concat(Vecrev(Str(p)))), p=nextprime(p+1)); p
terms(n) = my(i=0, k=1, s="", p=10); while(i < n, p=nextpalprime(p+1); s=Str(s, p); if(ispseudoprime(eval(s)), print1(k, ", "); i++); k++)
terms(3) \\ print initial three terms
(Python)
from sympy import isprime, nextprime
def ispal(n): strn = str(n); return strn == strn[::-1]
def agen():
np, p, pstr = 1, 11, "11"
while True:
if isprime(int(pstr)): yield np
p = nextprime(p)
while not ispal(p): p = nextprime(p)
np += 1
pstr += str(p)
for an in agen(): print(an, end=", ") # Michael S. Branicky, Jan 17 2021
CROSSREFS
Cf. A002385.
Sequence in context: A035022 A375891 A012117 * A371488 A122430 A009051
KEYWORD
nonn,base,more,bref
AUTHOR
Felix Fröhlich, Apr 07 2016
STATUS
approved