login
Let n range through the odd numbers skipping multiples of 5; a(n) = n-th prime ending in n.
2

%I #12 Dec 11 2017 02:46:14

%S 11,23,107,179,2411,3413,5417,4919,6121,5923,9127,8629,9931,10133,

%T 10937,11939,14741,14243,16747,16649,16451,18553,19157,19259,22961,

%U 22963,24767,25169,28571,24373,28277,31079,30181,29483,31687,33589,33091

%N Let n range through the odd numbers skipping multiples of 5; a(n) = n-th prime ending in n.

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

%e 2411 is the 11th prime ending in 11: (11, 211, ..., 2111, 2311, 2411)

%p f:= proc(n) local d,k,count;

%p d:= 10^(ilog10(n)+1);

%p count:= 0;

%p for k from 0 while count < n do

%p if isprime(k*d+n) then count:= count+1 fi

%p od;

%p (k-1)*d+n

%p end proc:

%p seq(seq(f(10*i+j),j=[1,3,7,9]),i=0..10); # _Robert Israel_, Dec 10 2017

%t NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; f[n_] := Block[{p = 2, c = 0, m = Floor[ Log[10, n] + 1]}, While[ If[ Mod[p, 10^m] == n, c++ ]; c < n, p = NextPrim[p]]; p]; Map[f, Select[ Table[n, {n, 1, 91, 2}], Mod[ #, 10] != 5 &]] (* _Robert G. Wilson v_, Nov 26 2003 *)

%K base,nonn

%O 1,1

%A _Amarnath Murthy_, Nov 24 2003

%E Extended by _Robert G. Wilson v_, Nov 26 2003