login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Triangle where n-th row contains the smallest n positive integers (listed in order) with exactly n nonleading 0's in their binary representations.
3

%I #13 Aug 24 2015 02:38:45

%S 2,4,9,8,17,18,16,33,34,36,32,65,66,68,72,64,129,130,132,136,144,128,

%T 257,258,260,264,272,288,256,513,514,516,520,528,544,576,512,1025,

%U 1026,1028,1032,1040,1056,1088,1152,1024,2049,2050,2052,2056,2064,2080,2112

%N Triangle where n-th row contains the smallest n positive integers (listed in order) with exactly n nonleading 0's in their binary representations.

%H Reinhard Zumkeller, <a href="/A131094/b131094.txt">Rows n = 1..125 of triangle, flattened</a>

%e Binary representations of the terms in the first few rows:

%e 10

%e 100, 1001

%e 1000, 10001, 10010

%e 10000, 100001, 100010, 100100

%p A080791 := proc(n) local bdigs ; bdigs := convert(n,base,2) ; nops(bdigs)-add(i,i=bdigs) ; end: A131094 := proc(n) local a,i; a := [] ; i := 2^n ; while nops(a) < n do while A080791(i) <> n do i := i+1 ; od: a := [op(a),i] ; i := i+1 ; od: RETURN(a) ; end: seq(op(A131094(n)),n=1..10) ; # _R. J. Mathar_, Oct 17 2007

%o (Haskell)

%o import Data.List (sort, nub)

%o a131094 n k = a131094_tabl !! (n-1) !! (k-1)

%o a131094_row n = a131094_tabl !! (n-1)

%o a131094_tabl = [2] : f 2 [2] where

%o f v ws = ys : f (v + 1) ys where

%o ys = take v $ nub $ sort $ concatMap h ws

%o h z = [2 * z, 4 * z + 1, 4 * z' + b] where (z', b) = divMod z 2

%o -- _Reinhard Zumkeller_, Feb 11 2015

%Y Cf. A081118, A131095.

%K nonn,tabl

%O 1,1

%A _Leroy Quet_, Jun 14 2007

%E More terms from _R. J. Mathar_, Oct 17 2007