login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Members p of a pair of primes (p,q) such that the decimal digits of q are the 9's complement of the decimal digits of p.
3

%I #16 Oct 06 2020 19:28:47

%S 2,7,23,61,67,83,107,109,127,163,167,181,211,223,227,239,241,251,263,

%T 269,271,277,283,293,307,367,383,389,401,409,421,461,463,467,487,509,

%U 521,523,563,587,601,607,613,617,631,641,643,647,653,661,673,677,683,701

%N Members p of a pair of primes (p,q) such that the decimal digits of q are the 9's complement of the decimal digits of p.

%C We consider length(p) = length(q). For example, the primes p = 97, 997, 99999999999999997,...(see A003618) are not in the sequence with q = 2.

%C Each prime p appears only once in the sequence, but the pair (p, q) is not unique, for example the prime 163 generates two pairs of primes(163, 683) and (163, 863), the prime 283 generates three pairs of primes(283, 167), (283, 617) and (283, 761).

%C The couples of primes (p, q) are (2, 7), (7, 2), (23, 67), (61, 83), (67, 23), (83, 61), (107, 829), (109, 809), (127, 827),...

%C In the general case, the digits of p are different from q, but there exists numbers p such that q has the same digits as p, for example (p, q) = (227, 277), (727, 227), (881, 181), ...

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

%e 23 is in the sequence because 9-2 = 7 and 9 - 3 = 6 => 67 is prime, and we obtain the pair (23, 67).

%p with(numtheory):kk:=0:

%p for n from 1 to 200 do:

%p ii:=0:

%p for k from 1 to 2000 while(ii=0) do:

%p p1:=ithprime(n):p2:=ithprime(k):

%p x1:=convert(p1,base,10):n1:=nops(x1):

%p x2:=convert(p2,base,10):n2:=nops(x2):

%p if n1=n2 then

%p W:=array(1..n1):U:=array(1..n1):U1:=array(1..n1):

%p for c from 1 to n1 do:

%p U1[c]:=x1[c]:od:U:=sort(x1,`<`):V:=sort(x2,`>`):

%p for j from 1 to n1 do:

%p W[j]:= 9-V[j]:od:W1:=sort(W,`>`):jj:=0:

%p for b from 1 to n1 do:

%p if U[b]=W1[b] then

%p jj:=jj+1:

%p else fi:

%p od:

%p if jj=n1 then

%p ii:=1: kk:=kk+1: printf(`%d, `,p1):

%p else

%p fi:

%p fi:

%p od:

%p od:

%p # Alternative:

%p R:= 2,7:

%p for d from 2 to 3 do

%p P:= select(isprime,[seq(i,i=10^(d-1)+1..10^d-1,2)]);

%p nP:= nops(P);

%p Pd:= map(sort@convert,P,base,10);

%p Ps:= convert(map(t -> ListTools:-Reverse([9$d]-t), Pd),set);

%p S:= select(t -> member(Pd[t],Ps),[$1..nP]);

%p R:= R, op(P[S]);

%p od:

%p R; # _Robert Israel_, Oct 06 2020

%Y Cf. A228628.

%K nonn,base

%O 1,1

%A _Michel Lagneau_, Aug 28 2013