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.

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

This page as a plain text file.
%I A059009 #49 Mar 10 2022 14:18:14
%S A059009 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 A059009 49,50,52,55,56,59,61,62,65,66,68,71,72,75,77,78,80,83,85,86,89,90,92,
%U A059009 95,96,99,101,102,105,106,108,111,113,114,116,119,120,123,125,126,128,131
%N A059009 Numbers having an odd number of zeros in their binary expansion.
%C A059009 Positions of ones in A059448 for n >= 1. - _John Keith_, Mar 09 2022
%H A059009 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 A059009 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 A059009 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 A059009 18 is in the sequence because 18 = 10010_2. '10010' has three zeros. - _Indranil Ghosh_, Feb 04 2017
%p A059009 a:= proc(n) option remember;
%p A059009   if n::even then -a(n/2) + 3*n + 1 else a((n-1)/2) + n + 1 fi
%p A059009 end proc:
%p A059009 a(0):= 0:
%p A059009 seq(a(n),n=0..100); # _Robert Israel_, Feb 23 2016
%t A059009 Select[Range[0,150],OddQ[Count[IntegerDigits[#,2],0]]&] (* _Harvey P. Dale_, Oct 22 2011 *)
%o A059009 (PARI) is(n)=hammingweight(bitneg(n,#binary(n)))%2 \\ _Charles R Greathouse IV_, Mar 26 2013
%o A059009 (PARI) a(n) = if(n==0,0, 2*n + (logint(n,2) - hammingweight(n) + 1) % 2); \\ _Kevin Ryde_, Mar 11 2021
%o A059009 (Haskell)
%o A059009 a059009 n = a059009_list !! (n-1)
%o A059009 a059009_list = filter (odd . a023416) [1..]
%o A059009 -- _Reinhard Zumkeller_, Jan 21 2014
%o A059009 (Python)
%o A059009 i=j=0
%o A059009 while j<=800:
%o A059009     if bin(i)[2:].count("0")%2:
%o A059009         print(str(j)+" "+str(i))
%o A059009         j+=1
%o A059009     i+=1 # _Indranil Ghosh_, Feb 04 2017
%o A059009 (R)
%o A059009 maxrow <- 4 # by choice
%o A059009 onezeros <- 1
%o A059009 for(m in 1:(maxrow+1)){
%o A059009   row <- onezeros[2^(m-1):(2^m-1)]
%o A059009   onezeros <- c(onezeros, c(1-row, row) )
%o A059009 }
%o A059009 a <- which(onezeros == 0)
%o A059009 a
%o A059009 # _Yosu Yurramendi_, Mar 28 2017
%Y A059009 Cf. A000069, A001969, A059010, A059011, A059012, A059013, A059014, A059448.
%Y A059009 Cf. A023416.
%K A059009 nonn,base,easy,nice
%O A059009 0,2
%A A059009 _Patrick De Geest_, Dec 15 2000