login
Integers that have a prime number of 0's in their binary expansion.
5

%I #22 May 01 2021 02:09:36

%S 4,8,9,10,12,17,18,19,20,21,22,24,25,26,28,32,35,37,38,39,41,42,43,44,

%T 45,46,49,50,51,52,53,54,56,57,58,60,65,66,68,71,72,75,77,78,79,80,83,

%U 85,86,87,89,90,91,92,93,94,96,99,101,102,103,105,106,107,108,109,110

%N Integers that have a prime number of 0's in their binary expansion.

%H Indranil Ghosh, <a href="/A144754/b144754.txt">Table of n, a(n) for n = 1..25000</a>

%e 66 written in binary is 1000010. This has five 0's and five is a prime. So 66 is included in the sequence.

%t Select[Range@ 120, PrimeQ@ DigitCount[#, 2, 0] &] (* _Michael De Vlieger_, Oct 26 2017 *)

%o (PARI) isok(n) = isprime(#binary(n) - hammingweight(n)); \\ _Michel Marcus_, Feb 23 2016

%o (Python)

%o from sympy import isprime

%o i=j=1

%o while j<=250:

%o if isprime(bin(i)[2:].count("0")):

%o print(str(j)+" "+str(i))

%o j+=1

%o i+=1 # _Indranil Ghosh_, Feb 03 2017

%Y Cf. A052294.

%K base,nonn

%O 1,1

%A _Leroy Quet_, Sep 20 2008

%E Many more terms from _Reikku Kulon_, Sep 21 2008

%E Name edited by _Michel Marcus_, Apr 30 2021