%I #32 Apr 03 2023 10:36:13
%S 2,3,181,191,373,383,787,797,919,929,10501,10601,11311,11411,12721,
%T 12821,13831,13931,15451,15551,16561,16661,19891,19991,30103,30203,
%U 30703,30803,32323,32423,35053,35153,38083,38183,70507,70607,77377,77477,78787,78887,93139
%N Gridgeman pairs in increasing order: pairs of palindromic primes which differ only in their middle digits whose difference is equal to 1.
%C It has been conjectured by Norman T. Gridgeman that infinitely many pairs of such primes exist (see second ref.)
%H Chai Wah Wu, <a href="/A246488/b246488.txt">Table of n, a(n) for n = 1..1000</a> n = 1..100 from Paolo P. Lava.
%H Mauro Fiorentini, <a href="http://www.bitman.name/math/article/342">Coppie di Gridgeman</a> (in Italian)
%H Mauro Fiorentini, <a href="http://www.bitman.name/math/article/809">Gridgeman (congettura di)</a> (in Italian)
%H Prime Curios!, <a href="https://t5k.org/curios/cpage/8733.html">181</a>
%e 181 and 191 is a Gridgeman pair because the two numbers are palindromic primes which differ only in their middle digits. Furthermore their middle digits differ only in one unit: 8 and 8 + 1 = 9.
%e The same for 30103 and 30203: middle digits are 1 and 1 + 1 = 2.
%p T:=proc(n) local i,x; x:=convert(n,base,10);
%p add(x[-i]*10^(i-1),i=1..nops(x)) end:
%p P:=proc(q) local a,b,j,k,n; j:=[]; a:=2; for n from 1 to q do
%p if (length(a) mod 2)=1 and T(a)=a then
%p b:=(trunc(a/10^trunc(length(a)/2))); if b mod 10<9 then b:=b+1:
%p b:=b*10^trunc(length(a)/2)+(a mod 10^trunc(length(a)/2));
%p if isprime(b) then j:=[op(j),a,b]: fi: fi: fi:
%p a:=nextprime(a): od; op(j); end: P(10^4);
%t Select[Partition[Select[Prime[Range[10000]],PalindromeQ],2,1],IntegerQ[ Log10[ #[[2]]-#[[1]]]]&]//Flatten (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, May 02 2020 *)
%o (PARI) ispal(v) = {for(i=1, #v\2, if (v[i] != v[#v-i+1], return(0));); return(1);};
%o isgpal(p) = {d = digits(p); if ((#d % 2) && ispal(d) && (ic = #d\2 +1) && (d[ic]<9) && (d[ic]++) && isprime(q=subst(Pol(d), x, 10)), q);}
%o lista(nn) = {forprime(p=2, nn, if (q=isgpal(p), print1(p, ", ", q, ", ")););} \\ _Michel Marcus_, Aug 29 2014
%o (Python)
%o from sympy import isprime
%o A246488 = [2,3]
%o for n in range(1,10**4):
%o ....s1 = str(n)
%o ....s2 = s1[::-1]
%o ....for m in range(10-1):
%o ........p1 = int(s1+str(m)+s2)
%o ........p2 = int(s1+str(m+1)+s2)
%o ........if isprime(p1) and isprime(p2):
%o ............A246488.append(p1), A246488.append(p2)
%o .
%o A246488 = sorted(set(A246488)) # _Chai Wah Wu_, Sep 05 2014
%Y Cf. A002385.
%K nonn,base
%O 1,1
%A _Paolo P. Lava_, Aug 28 2014