A081926 Triangle read by rows in which n-th row gives n smallest numbers with digit sum n.
1, 2, 11, 3, 12, 21, 4, 13, 22, 31, 5, 14, 23, 32, 41, 6, 15, 24, 33, 42, 51, 7, 16, 25, 34, 43, 52, 61, 8, 17, 26, 35, 44, 53, 62, 71, 9, 18, 27, 36, 45, 54, 63, 72, 81, 19, 28, 37, 46, 55, 64, 73, 82, 91, 109, 29, 38, 47, 56, 65, 74, 83, 92, 119, 128, 137
Offset: 1
Examples
Triangle starts 1 2 11 3 12 21 4 13 22 31 5 14 23 32 41
Links
- Robert Israel, Table of n, a(n) for n = 1..10011 (first 141 rows, flattened; first 40 rows from T. D. Noe)
Programs
-
Maple
f:= proc(n) local Res, d, v, count; Res:= NULL; count:= 0; for d from ceil(n/9) while count < n do v:= g(n,d,n-count,1); Res:= Res, op(v); count:= count + nops(v); od: Res end proc: g:= proc(n,d,remain) local rem, Res, j, j0, v; if remain = 0 then return [] else rem:= remain fi; if nargs = 4 then j0:= 1 else j0:= 0 fi; if d = 1 then if n >= j0 and n <= 9 then [n] else [] fi else Res:= NULL; for j from max(j0, ceil(n-9*(d-1))) to min(9,n) while rem > 0 do v:= map(t -> j*10^(d-1)+t, procname(n-j,d-1,rem)); Res:= Res, op(v); rem:= rem - nops(v); od; [Res] fi end proc: for i from 1 to 25 do f(i) od; # Robert Israel, Feb 19 2018
-
Mathematica
Needs["Combinatorica`"]; Table[Take[Union[Flatten[Table[FromDigits /@ Permutations[PadRight[s, 6]], {s, Partitions[n, 9]}]]], n], {n, 40}] (* T. D. Noe, Mar 08 2013 *)
Comments