OFFSET
1,1
COMMENTS
There are infinitely many n for which a(n+1) = a(n). For example, when 10^k + 1 is composite, 10^k - 1 and 10^k + 1 are successive palindromes which have the same next prime. - Robert Israel, Nov 04 2015
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..10000
FORMULA
MAPLE
digrev:= proc(x) option remember; local t;
t:= x mod 10;
t*10^ilog10(x)+procname((x-t)/10)
end proc:
for x from 0 to 9 do digrev(x):= x od:
N:=6;
Pals:= $1..9:
for d from 2 to N do
if d::even then
m:= d/2;
Pals:= Pals, seq(n*10^m + digrev(n), n=10^(m-1)..10^m-1);
else
m:= (d-1)/2;
Pals:= Pals, seq(seq(n*10^(m+1)+y*10^m+digrev(n), y=0..9), n=10^(m-1)..10^m-1);
fi
od:
Pals:=[Pals]:
map(nextprime, Pals); # Robert Israel, Nov 04 2015
MATHEMATICA
NextPrime[Select[Range[700], PalindromeQ]] (* Harvey P. Dale, Jan 31 2024 *)
PROG
(Python)
from sympy import nextprime
def A186698(n): return int(nextprime((c:=n+1-x)*x+int(str(c)[-2::-1] or 0) if n+1<(x:=10**(len(str(n+1>>1))-1))+(y:=10*x) else (c:=n+1-y)*y+int(str(c)[::-1] or 0))) # Chai Wah Wu, Jul 10 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Harvey P. Dale, Feb 25 2011
STATUS
approved