OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..25
EXAMPLE
a(6)=1011013 since it is the least prime that contains a palindromic substring (101101) of length 6.
PROG
(Python)
from sympy import isprime
from itertools import product
def pals_to_test(n, odd=True):
if n <= 2: yield [2, 11][n-1]
if odd: ruled_out = "024568" # can't be even or multiple of 5
else: ruled_out = "0"
midrange = [[""], [str(i) for i in range(10)]]
for p in product("0123456789", repeat=n//2):
left = "".join(p)
if len(left):
if left[0] in ruled_out: continue
for middle in midrange[n%2]:
out = left+middle+left[::-1]
if odd: yield out
else:
for last in "1379": yield out+last
def a(n):
palsgen = pals_to_test(n, n%2 == 1)
while True:
strpal = next(palsgen)
pal = int(strpal)
if isprime(pal): return pal
print([a(n) for n in range(1, 18)]) # Michael S. Branicky, Feb 11 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Giovanni Resta, Feb 06 2006
EXTENSIONS
a(18) and beyond from Michael S. Branicky, Feb 11 2021
STATUS
approved