login
Numbers n with property that, reading binary expansion of n from right to left, run lengths strictly increase.
18

%I #48 Sep 14 2021 17:33:04

%S 0,1,3,6,7,14,15,28,30,31,57,60,62,63,120,121,124,126,127,241,248,249,

%T 252,254,255,483,496,497,504,505,508,510,511,966,993,995,1008,1009,

%U 1016,1017,1020,1022,1023,1987,1990,2016,2017,2019,2032,2033,2040,2041,2044

%N Numbers n with property that, reading binary expansion of n from right to left, run lengths strictly increase.

%C There are A000009(k) elements of this list consisting of k bits. - _Jason Kimberley_, Jan 22 2013

%H Reinhard Zumkeller, <a href="/A037015/b037015.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%e From _Jason Kimberley_, Jan 30 2013: (Start)

%e Interleaved lines:

%e binary expansions,

%e corresponding run lengths (distinct partitions);

%e 1,

%e 1;

%e 11,

%e 2;

%e 110, 111,

%e 2,1; 3;

%e 1110, 1111,

%e 3,1; 4;

%e 11100, 11110, 11111,

%e 3,2; 4,1; 5;

%e 111001, 111100, 111110, 111111,

%e 3,2,1; 4,2; 5,1; 6;

%e 1111000, 1111001, 1111100, 1111110, 1111111,

%e 4,3; 4,2,1; 5,2; 6,1; 7;

%e 11110001, 11111000, 11111001, 11111100, 11111110, 11111111

%e 4,3,1; 5,3; 5,2,1; 6,2; 7,1; 8;

%e 111100011, 111110000, 111110001, 111111000, 111111001, 111111100, 111111110, 111111111,

%e 4,3,2; 5,4; 5,3,1; 6,3; 6,2,1; 7,2; 8,1; 9;

%e Notice the reversed sorting when a part corresponds to a run of 0's.

%e (End)

%t Select[Range[0,2500],Min[Differences[Length/@Split[ Reverse[ IntegerDigits[ #,2]]]]]>0&] (* _Harvey P. Dale_, Nov 18 2014 *)

%t Select[Range[0,2100],Max[Differences[Length/@Split[IntegerDigits[#,2]]]]<0&] (* _Harvey P. Dale_, Jun 28 2020 *)

%o (Haskell)

%o import Data.List (group)

%o a037015 n = a037015_list !! (n-1)

%o a037015_list = filter (all (> 0) . ds) [0..] where

%o ds x = zipWith (-) (tail gs) gs where

%o gs = map length $ group $ a030308_row x

%o -- _Reinhard Zumkeller_, Jul 31 2013, Mar 10 2012

%o (Python)

%o from itertools import groupby

%o A037015_list = []

%o for n in range(10**5):

%o c = None

%o for x, y in groupby(bin(n)[2:]):

%o z = len(list(y))

%o if c != None and z >= c:

%o break

%o c = z

%o else:

%o A037015_list.append(n) # _Chai Wah Wu_, Sep 14 2021

%Y Subsequence of A037016, cf. A037013, A037014.

%Y Cf. A030308.

%K nonn,easy,base,nice

%O 1,3

%A _N. J. A. Sloane_

%E More terms from _Patrick De Geest_, Feb 15 1999

%E Offset fixed and missing 1023 inserted by _Reinhard Zumkeller_, Mar 10 2012