login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A087117 Number of zeros in the longest string of consecutive zeros in the binary representation of n. 14
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.

LINKS

Reinhard Zumkeller, Table of n, a(n) for n = 0..10000

Index entries for sequences related to binary expansion of n

FORMULA

a(n) = max(A007814(n), a(A025480(n-1))) for n >= 2. - Robert Israel, Feb 19 2017

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

A087117 := proc(n)

    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 ;

end proc; # R. J. Mathar, Nov 05 2012

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)

-- Reinhard Zumkeller, May 01 2012

CROSSREFS

Cf. A023416, A007088, A007814.

Cf. A025480, A038374, A090046, A090047, A090048, A090049, A090050.

Sequence in context: A144789 A285097 A279209 * A029340 A288166 A126258

Adjacent sequences:  A087114 A087115 A087116 * A087118 A087119 A087120

KEYWORD

nonn,base

AUTHOR

Reinhard Zumkeller, Aug 14 2003

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 26 20:42 EDT 2019. Contains 321534 sequences. (Running on oeis4.)