|
|
A087117
|
|
Number of zeros in the longest string of consecutive zeros in the binary representation of n.
|
|
20
|
|
|
1, 0, 1, 0, 2, 1, 1, 0, 3, 2, 1, 1, 2, 1, 1, 0, 4, 3, 2, 2, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 0, 5, 4, 3, 3, 2, 2, 2, 2, 3, 2, 1, 1, 2, 1, 1, 1, 4, 3, 2, 2, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 0, 6, 5, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 4, 3, 2, 2, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 5, 4, 3, 3, 2, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,5
|
|
COMMENTS
|
The following four statements are equivalent: a(n) = 0; n = 2^k - 1 for some k > 0; A087116(n) = 0; A023416(n) = 0.
The k-th composition in standard order (row k of A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. Then a(k) is the maximum part of this composition, minus one. The maximum part is A333766(k). - Gus Wiseman, Apr 09 2020
|
|
LINKS
|
|
|
FORMULA
|
a(2n+1) = a(n) (n>=1); indeed, the binary form of 2n+1 consists of the binary form of n with an additional 1 at the end - Emeric Deutsch, Aug 18 2017
|
|
MAPLE
|
local d, l, zlen ;
if n = 0 then
return 1 ;
end if;
d := convert(n, base, 2) ;
for l from nops(d)-1 to 0 by -1 do
zlen := [seq(0, i=1..l)] ;
if verify(zlen, d, 'sublist') then
return l ;
end if;
end do:
return 0 ;
|
|
MATHEMATICA
|
nz[n_]:=Max[Length/@Select[Split[IntegerDigits[n, 2]], MemberQ[#, 0]&]]; Array[nz, 110, 0]/.-\[Infinity]->0 (* Harvey P. Dale, Sep 05 2017 *)
|
|
PROG
|
(Haskell)
import Data.List (unfoldr, group)
a087117 0 = 1
a087117 n
| null $ zs n = 0
| otherwise = maximum $ map length $ zs n where
zs = filter ((== 0) . head) . group .
unfoldr (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2)
(PARI) h(n)=if(n<2, return(0)); my(k=valuation(n, 2)); if(k, max(h(n>>k), k), n++; n>>=valuation(n, 2); h(n-1))
|
|
CROSSREFS
|
Positions of terms <= 1 are A003754.
Positions of terms > 0 are A062289.
Positions of first appearances are A131577.
The version for prime indices is A252735.
The version for minimum is A333767.
All of the following pertain to compositions in standard order (A066099):
- Constant compositions are A272919.
- Weakly decreasing compositions are A114994.
- Weakly increasing compositions are A225620.
- Strictly decreasing compositions are A333255.
- Strictly increasing compositions are A333256.
Cf. A029931, A048793, A061395, A087117, A228351, A328594, A333217, A333218, A333219, A333767, A333768.
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|