|
|
A246488
|
|
Gridgeman pairs in increasing order: pairs of palindromic primes which differ only in their middle digits whose difference is equal to 1.
|
|
4
|
|
|
2, 3, 181, 191, 373, 383, 787, 797, 919, 929, 10501, 10601, 11311, 11411, 12721, 12821, 13831, 13931, 15451, 15551, 16561, 16661, 19891, 19991, 30103, 30203, 30703, 30803, 32323, 32423, 35053, 35153, 38083, 38183, 70507, 70607, 77377, 77477, 78787, 78887, 93139
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
It has been conjectured by Norman T. Gridgeman that infinitely many pairs of such primes exist (see second ref.)
|
|
LINKS
|
|
|
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
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
|
|
|
STATUS
|
approved
|
|
|
|