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.

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

Original entry on oeis.org

2, 4, 6, 7, 10, 16, 20, 26, 28, 32, 38, 40, 46, 52, 56, 58, 62, 68, 70, 76, 80, 82, 86, 88, 92, 94, 96, 97, 112, 116, 118, 122, 136, 140, 142, 146, 160, 170, 172, 176, 178, 188, 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
Offset: 1

Views

Author

Pierandrea Formusa, Sep 03 2018

Keywords

Examples

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

Crossrefs

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

Programs

  • PARI
    complement(n) = my(d=digits(n)); for(k=1, #d, d[k]=9-d[k]); subst(Pol(d), x, 10)
    is(n) = ispseudoprime(complement(n)) \\ Felix Fröhlich, Sep 03 2018
  • Python
    nmax=500
    def is_prime(num):
        if num == 0 or num == 1: return(0)
        for k in range(2, num):
           if (num % k) == 0:
               return(0)
        return(1)
    def c9(num):
        s=str(num)
        l=len(str(num))
        n=""
        for k in range(l):
            n = n+str(9-int(s[k]))
        return(int(n))
    ris = ""
    for i in range(2,nmax):
        if is_prime(c9(i)):
           ris = ris+str(i)+","
    print(ris)