login

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

Numbers which are prime if each digit is replaced by its 9's complement.
2

%I #18 Sep 05 2018 15:12:35

%S 2,4,6,7,10,16,20,26,28,32,38,40,46,52,56,58,62,68,70,76,80,82,86,88,

%T 92,94,96,97,112,116,118,122,136,140,142,146,160,170,172,176,178,188,

%U 190,202,212,226,230,238,242,248,256,260,266,272,280,290,298,308,316,322,326,338,340,346,352,356,358

%N Numbers which are prime if each digit is replaced by its 9's complement.

%e 32 belongs to this sequence as its 9's complement is 67, which is prime.

%o (Python)

%o nmax=500

%o def is_prime(num):

%o if num == 0 or num == 1: return(0)

%o for k in range(2, num):

%o if (num % k) == 0:

%o return(0)

%o return(1)

%o def c9(num):

%o s=str(num)

%o l=len(str(num))

%o n=""

%o for k in range(l):

%o n = n+str(9-int(s[k]))

%o return(int(n))

%o ris = ""

%o for i in range(2,nmax):

%o if is_prime(c9(i)):

%o ris = ris+str(i)+","

%o print(ris)

%o (PARI) complement(n) = my(d=digits(n)); for(k=1, #d, d[k]=9-d[k]); subst(Pol(d), x, 10)

%o is(n) = ispseudoprime(complement(n)) \\ _Felix Fröhlich_, Sep 03 2018

%Y Cf. A061601 (9's complement of n).

%K nonn,base

%O 1,1

%A _Pierandrea Formusa_, Sep 03 2018