login
Number of blocks of {1,0} in the binary expansion of n.
18

%I #54 Jun 01 2021 02:14:04

%S 0,1,0,1,1,1,0,1,1,2,1,1,1,1,0,1,1,2,1,2,2,2,1,1,1,2,1,1,1,1,0,1,1,2,

%T 1,2,2,2,1,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2,1,1,1,2,1,1,1,1,0,1,1,2,1,2,

%U 2,2,1,2,2,3,2,2,2,2,1,2,2,3,2,3,3,3,2,2,2,3,2,2,2,2,1,1,1,2,1,2,2,2

%N Number of blocks of {1,0} in the binary expansion of n.

%C Number of i such that d(i) < d(i-1), where Sum_{d(i)*2^i: i=0,1,....,m} is base 2 representation of n.

%C This is the base-2 down-variation sequence; see A297330. - _Clark Kimberling_, Jan 18 2017

%H Reinhard Zumkeller, <a href="/A033264/b033264.txt">Table of n, a(n) for n = 1..10000</a>

%H Jean-Paul Allouche and Jeffrey Shallit, <a href="https://doi.org/10.1007/BFb0097122">Sums of digits and the Hurwitz zeta function</a>, in: K. Nagasaka and E. Fouvry (eds.), Analytic Number Theory, Lecture Notes in Mathematics, Vol. 1434, Springer, Berlin, Heidelberg, 1990, pp. 19-30.

%H Ralf Stephan, <a href="/somedcgf.html">Some divide-and-conquer sequences with (relatively) simple ordinary generating functions</a>, 2004.

%H Ralf Stephan, <a href="/A079944/a079944.ps">Table of generating functions</a>.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/DigitBlock.html">Digit Block</a>.

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F G.f.: 1/(1-x) * Sum_(k>=0, t^2/(1+t)/(1+t^2), t=x^2^k). - _Ralf Stephan_, Sep 10 2003

%F a(n) = A069010(n) - (n mod 2). - _Ralf Stephan_, Sep 10 2003

%F a(4n) = a(4n+1) = a(2n), a(4n+2) = a(n)+1, a(4n+3) = a(n). - _Ralf Stephan_, Aug 20 2003

%F a(n) = A087116(n) for n > 0, since strings of 0's alternate with strings of 1's, which end in (1,0). - _Jonathan Sondow_, Jan 17 2016

%F Sum_{n>=1} a(n)/(n*(n+1)) = Pi/4 - log(2)/2 (A196521) (Allouche and Shallit, 1990). - _Amiram Eldar_, Jun 01 2021

%p f:= proc(n) option remember; local k;

%p k:= n mod 4;

%p if k = 2 then procname((n-2)/4) + 1

%p elif k = 3 then procname((n-3)/4)

%p else procname((n-k)/2)

%p fi

%p end proc:

%p f(1):= 0: f(0):= q:

%p seq(f(i),i=1..100); # _Robert Israel_, Aug 31 2015

%t Table[Count[Partition[IntegerDigits[n, 2], 2, 1], {1, 0}], {n, 102}] (* _Michael De Vlieger_, Aug 31 2015, after _Robert G. Wilson v_ at A014081 *)

%t Table[SequenceCount[IntegerDigits[n,2],{1,0}],{n,110}] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Jan 26 2017 *)

%o (Haskell)

%o a033264 = f 0 . a030308_row where

%o f c [] = c

%o f c (0 : 1 : bs) = f (c + 1) bs

%o f c (_ : bs) = f c bs

%o -- _Reinhard Zumkeller_, Feb 20 2014, Jun 17 2012

%o (PARI)

%o a(n) = { hammingweight(bitand(n>>1, bitneg(n))) }; \\ _Gheorghe Coserea_, Aug 30 2015

%Y Cf. A014081, A014082, A037800, A056974, A056975, A056976, A056977, A056978, A056979, A056980, A196521.

%Y a(n) = A005811(n) - ceiling(A005811(n)/2) = A005811(n) - A069010(n).

%Y Equals (A072219(n+1)-1)/2.

%Y Cf. also A175047, A030308.

%Y Essentially the same as A087116.

%K nonn,base,easy

%O 1,10

%A _Clark Kimberling_