login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A108730 Triangle read by rows: row n gives the list of the number of zeros following each 1 in the binary representation of n. 7

%I #35 Sep 13 2023 04:42:02

%S 0,1,0,0,2,1,0,0,1,0,0,0,3,2,0,1,1,1,0,0,0,2,0,1,0,0,0,1,0,0,0,0,4,3,

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

%U 0,1,0,0,0,0,1,0,0,0,0,0,5,4,0,3,1,3,0,0,2,2,2,1,0,2,0,1,2,0,0,0,1,3,1,2,0

%N Triangle read by rows: row n gives the list of the number of zeros following each 1 in the binary representation of n.

%C This is probably the simplest method for putting the nonnegative integers into one-to-one correspondence with the finite sequences of nonnegative integers and is the standard ordering for such sequences in this database.

%C This sequence contains every finite sequence of nonnegative integers.

%C This can be regarded as a table in two ways: with each weak composition as a row, or with the weak compositions of each integer as a row. The first way has A000120 as row lengths and A080791 as row sums; the second has A001792 as row lengths and A001787 as row sums. - _Franklin T. Adams-Watters_, Nov 06 2006

%C Concatenate the base-two positive integers (A030190 less the initial zero). Left to right and disallowing leading zeros, reorganize the digits into the smallest possible numbers. These will be the base-two powers-of-two of A108730. - _Hans Havermann_, Nov 14 2009

%C T(2^(n-1),0) = n-1 and T(m,k) < n-1 for all m < 2^n, k <= A000120(m). When the triangle is seen as a flattened list, each n occurs first at position n*2^(n-1)+1, cf. A005183. - _Reinhard Zumkeller_, Feb 26 2012

%C Equals A066099-1, elementwise. - _Andrey Zabolotskiy_, May 18 2018

%H Franklin T. Adams-Watters, <a href="/A108730/b108730.txt">Table of n, a(n) for n = 1..5120 (through 10 bit numbers)</a>

%e Triangle begins:

%e 0

%e 1

%e 0,0

%e 2

%e 1,0

%e 0,1

%e 0,0,0

%e 3

%e For example, 25 = 11001_2; following the 1's are 0, 2 and 0 zeros, so row 25 is 0, 2, 0.

%t row[n_] := (id = IntegerDigits[n, 2]; sp = Split[id]; f[run_List] := If[First[run] == 0, run, Sequence @@ Table[{}, {Length[run] - 1}]]; len = Length /@ f /@ sp; If[Last[id] == 0, len, Append[len, 0]]); Flatten[ Table[row[n], {n, 1, 41}]] (* _Jean-François Alcover_, Jul 13 2012 *)

%o (Haskell)

%o import Data.List (unfoldr, group)

%o a108730 n k = a108730_tabf !! (n-1) !! (k-1)

%o a108730_row = f . group . reverse . unfoldr

%o (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2) where

%o f [] = []

%o f [os] = replicate (length os) 0

%o f (os:zs:dss) = replicate (length os - 1) 0 ++ [length zs] ++ f dss

%o a108730_tabf = map a108730_row [1..]

%o a108730_list = concat a108730_tabf

%o -- _Reinhard Zumkeller_, Feb 26 2012

%o (PARI) row(n)=my(v=vector(hammingweight(n)),t=n); for(i=0,#v-1,v[#v-i] = valuation(t,2); t>>=v[#v-i]+1); v \\ _Charles R Greathouse IV_, Sep 14 2015

%Y Cf. A066099 (main entry for compositions), A007088, A000120, A080791, A001792, A001787, A124735.

%K easy,base,nice,nonn,tabf

%O 1,5

%A _Franklin T. Adams-Watters_, Jun 22 2005

%E Edited by _Franklin T. Adams-Watters_, Nov 06 2006

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 20:33 EDT 2024. Contains 371916 sequences. (Running on oeis4.)