login
Largest palindromic number <= n-th-prime.
2

%I #13 Dec 18 2020 16:14:25

%S 2,3,5,7,11,11,11,11,22,22,22,33,33,33,44,44,55,55,66,66,66,77,77,88,

%T 88,101,101,101,101,111,121,131,131,131,141,151,151,161,161,171,171,

%U 181,191,191,191,191,202,222,222,222,232,232,232,242,252,262,262,262,272

%N Largest palindromic number <= n-th-prime.

%H Robert Israel, <a href="/A180458/b180458.txt">Table of n, a(n) for n = 1..10000</a>

%p # given lists Primes of primes and Palis of palindromes, with Palis[-1] > Primes[-1]

%p m:= 1; A:= 'A':

%p for n from 1 to nops(Primes) do

%p while m < nops(Palis) and Palis[m+1] <= Primes[n] do m:= m+1 od:

%p A[n]:= Palis[m]

%p od:

%p seq(A[i],i=1..nops(Primes)); # _Robert Israel_, Apr 26 2016

%t lpn[n_]:=Module[{k=0},While[!PalindromeQ[n-k],k++];n-k]; Table[lpn[n],{n,Prime[Range[60]]}] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Dec 18 2020 *)

%Y Cf. A000040, A261423.

%K base,nonn

%O 1,1

%A _Giovanni Teofilatto_, Sep 06 2010

%E Corrected by _Robert Israel_, Apr 26 2016