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.

A380786 Numbers with a prime number of bits, prime number of ones, and prime number of zeros in their binary representation.

This page as a plain text file.
%I A380786 #51 Feb 27 2025 15:08:48
%S A380786 17,18,19,20,21,22,24,25,26,28,65,66,68,72,79,80,87,91,93,94,96,103,
%T A380786 107,109,110,115,117,118,121,122,124,4097,4098,4100,4104,4112,4128,
%U A380786 4160,4224,4352,4608,5119,5120,5631,5887,6015,6079,6111,6127,6135,6139,6141,6142,6144,6655,6911
%N A380786 Numbers with a prime number of bits, prime number of ones, and prime number of zeros in their binary representation.
%C A380786 Each term has either two zeros or two ones in its binary representation. And so the total number of bits of each term is the larger prime of a twin prime pair.
%H A380786 Michael S. Branicky, <a href="/A380786/b380786.txt">Table of n, a(n) for n = 1..10000</a>
%e A380786 a(1) = 17 = 10001_2. Number of bits is 5, number of ones is 2, number of zeros is 3. {2,3,5} are all primes.
%t A380786 Select[Range[2^13], AllTrue[{#1, #2, #1 - #2} & @@ {IntegerLength[#,2], DigitCount[#, 2, 1]}, PrimeQ] & ] (* _Michael De Vlieger_, Feb 03 2025 *)
%o A380786 (Python)
%o A380786 from sympy import isprime
%o A380786 def ok(n): return isprime(L:=n.bit_length()) and isprime(O:=n.bit_count()) and isprime(L-O)
%o A380786 print([k for k in range(7160) if ok(k)]) # _Michael S. Branicky_, Feb 03 2025
%o A380786 (Python)
%o A380786 from sympy import isprime, nextprime, sieve
%o A380786 from itertools import combinations, count, islice
%o A380786 def agen(): # generator of terms
%o A380786     p = 5
%o A380786     while True:
%o A380786         passed = set()
%o A380786         if isprime(p-2):
%o A380786             for q in [2, p-2]:
%o A380786                 for locs in combinations(range(1, p), q-1):
%o A380786                     w = ["1"] + ["0"]*(p-1)
%o A380786                     for i in locs: w[i] = "1"
%o A380786                     passed.add(int("".join(w), 2))
%o A380786         yield from sorted(passed)
%o A380786         p = nextprime(p)
%o A380786         print(len(passed), p)
%o A380786 print(list(islice(agen(), 61))) # _Michael S. Branicky_, Feb 03 2025
%o A380786 (PARI) isok(k) = my(h=hammingweight(k), b=#binary(k)); isprime(h) && isprime(b) && isprime(b-h); \\ _Michel Marcus_, Feb 07 2025
%Y A380786 Intersection of A052294, A144754, and A380788.
%Y A380786 Subsequence of primes gives A272478.
%Y A380786 Subsequence of A343258.
%Y A380786 Cf. A006512 (bitlengths of terms).
%K A380786 nonn,base
%O A380786 1,1
%A A380786 _Marc Morgenegg_, Feb 03 2025