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.

Showing 1-1 of 1 results.

A339268 The smallest prime that becomes 2 * prime(n), when all the bits in its binary expansion are inverted, or -1 if no such prime exists.

Original entry on oeis.org

11, 549755813881, 53, 17, 41, 37, 16349, 89, 977, 197, 193, 181, 173, 937, 929, 149, 137, 389, 1913, 881, 877, 353, 857, 3917, 317, 821, 3889, 809, 293, 797, 257, 761, 3821, 65257, 3797, 3793, 709, 1721, 3761, 677, 1048217, 661, 641, 3709, 3701, 3697, 601, 577
Offset: 1

Views

Author

Bob Andriesse, Nov 29 2020

Keywords

Comments

Conjecture: a(n) > 0 for all n.
a(6705), for prime(6705) = 67289, is either -1 or greater than (2^62500 - 1) * 262144 + 127565, which has 18820 digits. - Michael S. Branicky, Dec 05 2020

Examples

			a(1) = 11, because 11 = 1011_2 -inv-> 0100_2 = 4 = 2 * 2.
a(2) = 549755813881, because 549755813881 = 111111111111111111111111111111111111001_2 -inv-> 110_2 = 6 = 2 * 3. No smaller prime generates 3.
a(3) = 53, because 53 = 110101_2 -inv-> 001010_2 = 10 = 2 * 5.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{q = 2*Prime[n], m, r}, m = 2^Ceiling@Log2[q]; r = m - q - 1; While[r < q || ! PrimeQ[r], r += m; m *= 2]; r]; Array[a, 48] (* Amiram Eldar, Dec 04 2020 *)
  • PARI
    a(n) = {my(b = apply(x->1-x, binary(2*prime(n))), e=#b, q=fromdigits(b, 2)+2^e); while (!isprime(q), e++; q+=2^e; q); q;} \\ Michel Marcus, Dec 04 2020
  • Python
    from sympy import isprime
    from sympy import prime
    for i in range(1,50):
      d=2*prime(i)
      l=len(bin(d).lstrip('0b'))
      xor=2**l-1
      p=d^xor+2**l
      while not isprime(p):
       l+=1
       p+=2**l
      print(p,end=', ')
    
Showing 1-1 of 1 results.