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.

A066196 Primes which have an equal number of zeros and ones in their binary expansion.

This page as a plain text file.
%I A066196 #31 Jun 24 2025 15:10:08
%S A066196 2,37,41,139,149,163,197,541,557,563,569,587,601,613,617,647,653,659,
%T A066196 661,677,709,787,809,929,2141,2203,2221,2251,2281,2333,2347,2357,2381,
%U A066196 2389,2393,2417,2467,2473,2617,2659,2699,2707,2713,2729,2837,2851,2857
%N A066196 Primes which have an equal number of zeros and ones in their binary expansion.
%H A066196 Amiram Eldar, <a href="/A066196/b066196.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from Harry J. Smith)
%F A066196 A000040 INTERSECT A031443. - _R. J. Mathar_, Jun 01 2011
%t A066196 Prime[ Select[ Range[ 10^3 ], Count[ IntegerDigits[ Prime[ # ], 2 ], 0 ] == Count[ IntegerDigits[ Prime[ # ], 2 ], 1 ] & ] ]
%t A066196 digBalQ[n_] := Module[{d = IntegerDigits[n, 2], m}, EvenQ@(m = Length@d) && Count[d, 1] == m/2]; Select[Range[3000], PrimeQ[#] && digBalQ[#] &] (* _Amiram Eldar_, Nov 21 2020 *)
%t A066196 Select[Prime[Range[500]],DigitCount[#,2,1]==DigitCount[#,2,0]&] (* _Harvey P. Dale_, Jun 24 2025 *)
%o A066196 (PARI) isok(p) = isprime(p) && (2*hammingweight(p) == #binary(p)); \\ _Michel Marcus_, May 16 2022
%o A066196 (Python)
%o A066196 from itertools import count, islice
%o A066196 from sympy import isprime
%o A066196 from sympy.utilities.iterables import multiset_permutations
%o A066196 def agen():
%o A066196     yield from filter(isprime, (int("1"+"".join(p), 2) for n in count(1) for p in multiset_permutations("0"*n+"1"*(n-1))))
%o A066196 print(list(islice(agen(), 50))) # _Michael S. Branicky_, May 15 2022
%Y A066196 Cf. A000040, A031443.
%K A066196 nonn,base
%O A066196 1,1
%A A066196 _Robert G. Wilson v_, Dec 15 2001