%I #25 Oct 10 2017 10:29:36
%S 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,3,2,1,
%T 1,0,0,0,0,1,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,4,3,2,2,1,
%U 1,1,1,1,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,3,2,1,1,0,0,0
%N Number of blocks of {0, 0, 0} in the binary expansion of n.
%C Overlaps count. For example, 64 in binary is 1000000, which means that a(64) = 4, not 2. - _Harvey P. Dale_, Jan 10 2016
%H Antti Karttunen, <a href="/A056974/b056974.txt">Table of n, a(n) for n = 1..65537</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(1) = 0, and then after, a(2n) = a(n) + [n congruent to 0 mod 8], a(2n+1) = a(n). - _Ralf Stephan_, Aug 22 2003, corrected by _Antti Karttunen_, Oct 10 2017
%t a[n_, bits_] := (idn = IntegerDigits[n, 2]; ln = Length[idn]; lb = Length[bits]; For[cnt = 0; k = 1, k <= ln - lb + 1, k++, If[idn[[k ;; k + lb - 1]] == bits, cnt++]]; cnt); Table[ a[n, {0, 0, 0}], {n, 1, 102} ] (* _Jean-François Alcover_, Oct 23 2012 *)
%t Table[SequenceCount[IntegerDigits[n,2],{0,0,0},Overlaps->True],{n,110}] (* The program uses the SequenceCount function from Mathematica version 10 *) (* _Harvey P. Dale_, Jan 10 2016 *)
%o (PARI) a(n)=my(v=binary(n));sum(i=3,#v,v[i]+v[i-1]+v[i-2]==0) \\ _Charles R Greathouse IV_, Dec 07 2011
%o (PARI)
%o a(n) = {
%o my(x = bitor(n, bitor(n>>1, n>>2)));
%o if (x == 0, 0, 1 + logint(x, 2) - hammingweight(x))
%o };
%o vector(102, i, a(i)) \\ _Gheorghe Coserea_, Sep 17 2015
%o (Scheme)
%o ;; This uses Ralf Stephan's recurrence and memoization-macro definec:
%o (definec (A056974 n) (cond ((= 1 n) 0) ((even? n) (+ (if (zero? (modulo n 8)) 1 0) (A056974 (/ n 2)))) (else (A056974 (/ (- n 1) 2))))) ;; _Antti Karttunen_, Oct 10 2017
%Y Cf. A014082, A056974, A056975, A056976, A056977, A056978, A056979, A056980.
%K nonn,base,easy
%O 1,16
%A _Eric W. Weisstein_