%I #38 Oct 18 2021 13:12:02
%S 1,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,
%T 2,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,
%U 2,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
%N Number of maximal groups of consecutive zeros in binary representation of n.
%C The following four statements are equivalent: a(n) = 0; n = 2^k - 1 for some k; A087117(n) = 0; A023416(n) = 0.
%H Reinhard Zumkeller, <a href="/A087116/b087116.txt">Table of n, a(n) for n = 0..10000</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F a(n) = A033264(n) for n > 0 since strings of 0's alternate with strings of 1's. - _Jonathan Sondow_, Jan 17 2016
%F a(n) = a(2*n + 1) = a(4*n + 2) - 1, if n > 0. - _Michael Somos_, Nov 04 2016
%F a(n) = A069010(A003817(n)-n) for n > 0. - _Chai Wah Wu_, Nov 04 2016
%e G.f. = 1 + x^2 + x^4 + x^5 + x^6 + x^8 + x^9 + 2*x^10 + x^11 + x^12 + x^13 + x^14 + ...
%t a[n_] := SequenceCount[IntegerDigits[n, 2], {Longest[0..]}];
%t Table[a[n], {n, 0, 101}] (* _Jean-François Alcover_, Oct 18 2021 *)
%o (Haskell)
%o a087116 0 = 1
%o a087116 n = f 0 n where
%o f y 0 = y
%o f y x = if r == 0 then g x' else f y x'
%o where (x', r) = divMod x 2
%o g z = if r == 0 then g z' else f (y + 1) z'
%o where (z', r) = divMod z 2
%o -- _Reinhard Zumkeller_, Mar 31 2015
%o (PARI)
%o a(n) = if (n == 0, 1, hammingweight(bitxor(n, n>>1)) >> 1);
%o vector(102, i, a(i-1)) \\ _Gheorghe Coserea_, Sep 17 2015
%o (Python)
%o def A087116(n):
%o return sum(1 for d in bin(n)[2:].split('1') if len(d)) # _Chai Wah Wu_, Nov 04 2016
%Y Cf. A087118, A087119, A087120, A023416, A007088.
%Y Cf. A023416, A087117.
%Y Cf. A033264, A003817, A069010.
%Y Essentially the same as A033264.
%K nonn
%O 0,11
%A _Reinhard Zumkeller_, Aug 14 2003
|