login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Number of blocks of {1, 0, 1} in binary expansion of n.
11

%I #21 Sep 24 2015 10:52:23

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

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

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

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

%C a(n) = A213629(n,5) for n > 4. - _Reinhard Zumkeller_, Jun 17 2012

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

%H J.-P. Allouche, J. Shallit, <a href="http://www.math.jussieu.fr/~allouche/kreg2.ps">The Ring of k-regular Sequences II</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 a(2n) = a(n), a(2n+1) = a(n) + [n congruent to 2 mod 4]. - _Ralf Stephan_, Aug 22 2003

%t a[1] = a[2] = 0; a[n_] := a[n] = If[EvenQ[n], a[n/2], a[(n - 1)/2] + Boole[Mod[(n - 1)/2, 4] == 2]]; Table[a[n], {n, 1, 102}] (* _Jean-François Alcover_, Oct 22 2012, after _Ralf Stephan_ *)

%o (Haskell)

%o import Data.List (tails, isPrefixOf)

%o a056979 = sum . map (fromEnum . ([1,0,1] `isPrefixOf`)) .

%o tails . a030308_row

%o -- _Reinhard Zumkeller_, Jun 17 2012

%o (PARI) a(n) = hammingweight(bitnegimply(bitand(n, n>>2), n>>1));

%o vector(102, i, a(i)) \\ _Gheorghe Coserea_, Sep 17 2015

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

%K nonn,easy

%O 1,21

%A _Eric W. Weisstein_