OFFSET
1,1
COMMENTS
It has been conjectured by Norman T. Gridgeman that infinitely many pairs of such primes exist (see second ref.)
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..1000 n = 1..100 from Paolo P. Lava.
Mauro Fiorentini, Coppie di Gridgeman (in Italian)
Mauro Fiorentini, Gridgeman (congettura di) (in Italian)
Prime Curios!, 181
EXAMPLE
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.
The same for 30103 and 30203: middle digits are 1 and 1 + 1 = 2.
MAPLE
T:=proc(n) local i, x; x:=convert(n, base, 10);
add(x[-i]*10^(i-1), i=1..nops(x)) end:
P:=proc(q) local a, b, j, k, n; j:=[]; a:=2; for n from 1 to q do
if (length(a) mod 2)=1 and T(a)=a then
b:=(trunc(a/10^trunc(length(a)/2))); if b mod 10<9 then b:=b+1:
b:=b*10^trunc(length(a)/2)+(a mod 10^trunc(length(a)/2));
if isprime(b) then j:=[op(j), a, b]: fi: fi: fi:
a:=nextprime(a): od; op(j); end: P(10^4);
MATHEMATICA
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 *)
PROG
(PARI) ispal(v) = {for(i=1, #v\2, if (v[i] != v[#v-i+1], return(0)); ); return(1); };
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); }
lista(nn) = {forprime(p=2, nn, if (q=isgpal(p), print1(p, ", ", q, ", ")); ); } \\ Michel Marcus, Aug 29 2014
(Python)
from sympy import isprime
A246488 = [2, 3]
for n in range(1, 10**4):
....s1 = str(n)
....s2 = s1[::-1]
....for m in range(10-1):
........p1 = int(s1+str(m)+s2)
........p2 = int(s1+str(m+1)+s2)
........if isprime(p1) and isprime(p2):
.
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Paolo P. Lava, Aug 28 2014
STATUS
approved