OFFSET
1,1
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
EXAMPLE
1311131 contains the palindrome 111.
MATHEMATICA
NextPalindrome[n_] := Block[ {l = Floor[ Log[ 10, n] + 1], idn = IntegerDigits[ n]}, If[ Union[ idn] == {9}, Return[n + 2], If[l < 2, Return[n + 1], If[ FromDigits[ Reverse[ Take[ idn, Ceiling[l/2]]]] FromDigits[ Take[ idn, -Ceiling[l/2]]], FromDigits[ Join[ Take[ idn, Ceiling[l/2]], Reverse[ Take[ idn, Floor[l/2]]]]],
idfhn = FromDigits[ Take[ idn, Ceiling[l/2]]] + 1; idp = FromDigits[ Join[ IntegerDigits[ idfhn], Drop[ Reverse[ IntegerDigits[ idfhn]], Mod[l, 2]]]] ]]]]; f[n_] := Block[{k = 0, s = ToString[n]}, While[ !PrimeQ[k] || FromDigits[ Reverse[ IntegerDigits[k]]] != k || StringPosition[ ToString[k], s] == {}, k++ ]; k]; Map[f, NestList[ NextPalindrome, 0, 40]]
PROG
(Python)
from itertools import count
from sympy import isprime
def A085054(n):
s = str((c:=n-x)*x+int(str(c)[-2::-1] or 0) if n<(x:=10**(len(str(n>>1))-1))+(y:=10*x) else (c:=n-y)*y+int(str(c)[::-1] or 0))
for k in count(n):
p = (c:=k-x)*x+int(str(c)[-2::-1] or 0) if k<(x:=10**(len(str(k>>1))-1))+(y:=10*x) else (c:=k-y)*y+int(str(c)[::-1] or 0)
if s in str(p) and isprime(p):
return p # Chai Wah Wu, Jul 11 2024
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy and Meenakshi Srikanth (menakan_s(AT)yahoo.com), Jun 26 2003
EXTENSIONS
Edited, corrected and extended by Robert G. Wilson v, Jun 28 2003
STATUS
approved