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”).

a(n) = largest n-digit prime p whose reversal is a prime q > p.
2

%I #12 Aug 16 2016 21:09:51

%S 79,769,9679,98999,995699,9975899,99967999,999548999,9999049999,

%T 99994169999,999989299999,9999954799999,99999904999999,

%U 999999778999999,9999999349999999,99999994999999999,999999971189999999,9999999950999999999,99999999632999999999

%N a(n) = largest n-digit prime p whose reversal is a prime q > p.

%H Robert Israel, <a href="/A152034/b152034.txt">Table of n, a(n) for n = 2..200</a>

%p revdigs:= proc(x) local L,i; L:= convert(x,base,10); add(L[-i]*10^(i-1),i=1..nops(L)) end proc:

%p f:= proc(n)

%p local d,a,B,r;

%p for d from floor(n/2) by -1 do

%p B:= (10^d-1)*(1+10^(n-d));

%p for a from 10^(n-2*d)-1 to 1 by -1 do

%p r:= revdigs(a);

%p if r > a and isprime(B+10^d*a) and isprime(B+10^d*r) then return B+10^d*a fi

%p od

%p od

%p end proc:

%p map(f, [$2..20]); # _Robert Israel_, Aug 16 2016

%t Do[ p = NextPrime[10^(n ), -1 ]; Do[ p1 = FromDigits[ Reverse[IntegerDigits[p]]]; If[PrimeQ[p1] && p1 > p, Print[{n, p}]; Break[]]; p = NextPrime[p, -1], {10^9}], {n, 2, 15}];

%Y Cf. A006567, A152014, A152033.

%K nonn,base

%O 2,1

%A _Zak Seidov_, Nov 20 2008

%E More terms from _Max Alekseyev_, May 03 2011