login
Palindromic primes with middle digit 3.
1

%I #26 Sep 08 2022 08:45:10

%S 3,131,10301,11311,13331,14341,16361,19391,32323,35353,71317,76367,

%T 77377,79397,94349,97379,98389,1003001,1043401,1093901,1123211,

%U 1153511,1163611,1183811,1193911,1243421,1253521,1273721,1303031,1333331,1343431,1363631,1463641

%N Palindromic primes with middle digit 3.

%C Palindromic primes in the usual sense (i.e. A002385, not A007500).

%H Chai Wah Wu, <a href="/A082439/b082439.txt">Table of n, a(n) for n = 1..10000</a>

%p revdigs := proc(n)

%p local L, nL, j;

%p L:= convert(n, base, 10);

%p nL:= nops(L);

%p add(L[i]*10^(nL-i), i=1..nL);

%p end:

%p select(isprime, [3,seq(seq(n*10^(d+1)+3*10^d + revdigs(n), n=10^(d-1) .. 10^d-1), d= 1..4)]); # _Robert Israel_, Nov 11 2015

%t ppmd3Q[n_]:=Module[{idn=IntegerDigits[n],len},len=Length[idn];OddQ[len] && idn==Reverse[idn]&&idn[[(len+1)/2]]==3]; Select[Prime[ Range[ 120000]], ppmd3Q] (* _Harvey P. Dale_, Feb 12 2015 *)

%o (Magma) [ p: p in PrimesUpTo(200000000) | IsOdd(d) and D[(d+1) div 2] eq 3 and D eq Reverse(D) where d is #D where D is Intseq(p) ]; // _Vincenzo Librandi_, Apr 12 2011

%o (Python)

%o from gmpy2 import is_prime

%o A082439_list = [3]

%o for i in range(1,10**6):

%o s = str(i)

%o n = int(s+'3'+s[::-1])

%o if is_prime(n):

%o A082439_list.append(n) # _Chai Wah Wu_, Nov 11 2015

%Y Cf. A002385.

%K nonn,base

%O 1,1

%A _Lekraj Beedassy_, Apr 25 2003

%E Added a(4), a(13), a(14), a(28) by _Vincenzo Librandi_, Apr 12 2011