cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A228629 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.

Original entry on oeis.org

2, 7, 23, 61, 67, 83, 107, 109, 127, 163, 167, 181, 211, 223, 227, 239, 241, 251, 263, 269, 271, 277, 283, 293, 307, 367, 383, 389, 401, 409, 421, 461, 463, 467, 487, 509, 521, 523, 563, 587, 601, 607, 613, 617, 631, 641, 643, 647, 653, 661, 673, 677, 683, 701
Offset: 1

Views

Author

Michel Lagneau, Aug 28 2013

Keywords

Comments

We consider length(p) = length(q). For example, the primes p = 97, 997, 99999999999999997,...(see A003618) are not in the sequence with q = 2.
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).
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),...
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), ...

Examples

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

Crossrefs

Cf. A228628.

Programs

  • Maple
    with(numtheory):kk:=0:
        for n from 1 to 200 do:
          ii:=0:
            for k from 1 to 2000 while(ii=0) do:
            p1:=ithprime(n):p2:=ithprime(k):
            x1:=convert(p1,base,10):n1:=nops(x1):
            x2:=convert(p2,base,10):n2:=nops(x2):
             if n1=n2 then
             W:=array(1..n1):U:=array(1..n1):U1:=array(1..n1):
               for c from 1 to n1 do:
               U1[c]:=x1[c]:od:U:=sort(x1,`<`):V:=sort(x2,`>`):
                 for j from 1 to n1 do:
                 W[j]:= 9-V[j]:od:W1:=sort(W,`>`):jj:=0:
                   for b from 1 to n1 do:
                     if U[b]=W1[b] then
                     jj:=jj+1:
                     else fi:
                   od:
                     if jj=n1 then
                      ii:=1: kk:=kk+1: printf(`%d, `,p1):
                      else
                     fi:
               fi:
            od:
           od:
    # Alternative:
    R:= 2,7:
    for d from 2 to 3 do
      P:= select(isprime,[seq(i,i=10^(d-1)+1..10^d-1,2)]);
      nP:= nops(P);
      Pd:= map(sort@convert,P,base,10);
      Ps:= convert(map(t -> ListTools:-Reverse([9$d]-t), Pd),set);
      S:= select(t -> member(Pd[t],Ps),[$1..nP]);
      R:= R, op(P[S]);
    od:
    R; # Robert Israel, Oct 06 2020