login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A186698
Next prime after n-th positive palindrome.
2
2, 3, 5, 5, 7, 7, 11, 11, 11, 13, 23, 37, 47, 59, 67, 79, 89, 101, 103, 113, 127, 137, 149, 157, 163, 173, 191, 193, 211, 223, 223, 233, 251, 257, 263, 277, 283, 293, 307, 317, 331, 337, 347, 359, 367, 379, 389, 397, 409, 419, 431, 439, 449, 457, 467, 479, 487, 499, 509, 521, 541, 541, 547, 557, 569, 577, 587, 599, 607, 617, 631, 641, 647
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
FORMULA
a(n) = A151800(A002113(n+1)). - Michael S. Branicky, Jul 10 2024
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