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.

A322743 Least composite such that complementing one bit in its binary representation at a time produces exactly n primes.

Original entry on oeis.org

8, 4, 6, 15, 21, 45, 111, 261, 1605, 1995, 4935, 8295, 69825, 268155, 550725, 4574955, 13996605, 12024855, 39867135, 398467245, 1698754365, 16351800465, 72026408685, 120554434875
Offset: 0

Views

Author

Paolo P. Lava, Dec 24 2018

Keywords

Examples

			a(1) = 4 because 4 in base 2 is 100 and 000 is 0, 110 is 6 and 101 is 5: hence only one prime.
a(2) = 6 because 6 in base 2 is 110 and 010 is 2, 100 is 4 and 111 is 7: hence two primes.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) local k; for k from 2^n+1 while isprime(k) or n<>add(
          `if`(isprime(Bits[Xor](k, 2^j)), 1, 0), j=0..ilog2(k)) do od; k
        end:
    seq(a(n), n=0..12);  # Alois P. Heinz, Jan 03 2019
  • Python
    from sympy import isprime
    def A322743(n):
        i = 4 if n <= 1 else 2**n+1
        j = 1 if n <= 2 else 2
        while True:
            if not isprime(i):
                c = 0
                for m in range(len(bin(i))-2):
                    if isprime(i^(2**m)):
                        c += 1
                    if c > n:
                        break
                if c == n:
                    return i
            i += j # Chai Wah Wu, Jan 03 2019

Formula

From Chai Wah Wu, Jan 03 2019: (Start)
a(n) >= 2^n+1, if it exists. a(n) is odd for n > 2, if it exists.
It is clear these are true for n <= 2. Suppose n > 2. If a(n) is even, then complementing any bits that is not LSB or MSB will result in an even nonprime number. If a(n) is odd, then complementing the LSB will result in an even nonprime number. So either case shows that a(n) has n+1 or more binary bits. It also shows that a(n) must be odd.
Conjecture: a(n) mod 10 == 5 for n > 7. (End)
a(24) <= 794688308295. - Michael S. Branicky, Apr 25 2025

Extensions

Definition clarified by Chai Wah Wu, Jan 03 2019
a(19) added and a(0) corrected by Rémy Sigrist, Jan 03 2019
a(20)-a(23) from Giovanni Resta, Jan 03 2019