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.
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
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.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..6704
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=', ')
Comments