login
Numbers having an odd number of zeros in their binary expansion.
15

%I #49 Mar 10 2022 14:18:14

%S 0,2,5,6,8,11,13,14,17,18,20,23,24,27,29,30,32,35,37,38,41,42,44,47,

%T 49,50,52,55,56,59,61,62,65,66,68,71,72,75,77,78,80,83,85,86,89,90,92,

%U 95,96,99,101,102,105,106,108,111,113,114,116,119,120,123,125,126,128,131

%N Numbers having an odd number of zeros in their binary expansion.

%C Positions of ones in A059448 for n >= 1. - _John Keith_, Mar 09 2022

%H Indranil Ghosh, <a href="/A059009/b059009.txt">Table of n, a(n) for n = 0..25000</a> (terms 0..1000 from T. D. Noe)

%H Jeffrey Shallit, <a href="https://arxiv.org/abs/2112.13627">Additive Number Theory via Automata and Logic</a>, arXiv:2112.13627 [math.NT], 2021.

%F a(0) = 0, a(2*n) = -a(n) + 6*n + 1, a(2*n+1) = a(n) + 2*n + 2. a(n) = 2*n + 1/2(1-(-1)^A023416(n)) = 2*n + A059448(n). - _Ralf Stephan_, Sep 17 2003

%e 18 is in the sequence because 18 = 10010_2. '10010' has three zeros. - _Indranil Ghosh_, Feb 04 2017

%p a:= proc(n) option remember;

%p if n::even then -a(n/2) + 3*n + 1 else a((n-1)/2) + n + 1 fi

%p end proc:

%p a(0):= 0:

%p seq(a(n),n=0..100); # _Robert Israel_, Feb 23 2016

%t Select[Range[0,150],OddQ[Count[IntegerDigits[#,2],0]]&] (* _Harvey P. Dale_, Oct 22 2011 *)

%o (PARI) is(n)=hammingweight(bitneg(n,#binary(n)))%2 \\ _Charles R Greathouse IV_, Mar 26 2013

%o (PARI) a(n) = if(n==0,0, 2*n + (logint(n,2) - hammingweight(n) + 1) % 2); \\ _Kevin Ryde_, Mar 11 2021

%o (Haskell)

%o a059009 n = a059009_list !! (n-1)

%o a059009_list = filter (odd . a023416) [1..]

%o -- _Reinhard Zumkeller_, Jan 21 2014

%o (Python)

%o i=j=0

%o while j<=800:

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

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

%o j+=1

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

%o (R)

%o maxrow <- 4 # by choice

%o onezeros <- 1

%o for(m in 1:(maxrow+1)){

%o row <- onezeros[2^(m-1):(2^m-1)]

%o onezeros <- c(onezeros, c(1-row, row) )

%o }

%o a <- which(onezeros == 0)

%o a

%o # _Yosu Yurramendi_, Mar 28 2017

%Y Cf. A000069, A001969, A059010, A059011, A059012, A059013, A059014, A059448.

%Y Cf. A023416.

%K nonn,base,easy,nice

%O 0,2

%A _Patrick De Geest_, Dec 15 2000