editing
approved
editing
approved
b:= proc(n, k, l) option remember; `if`(k=0, 1,
`if`(l=0, 0, add(b(n, k-j, l-1), j=0..min(n-1, k))))
end:
T:= (n, k)-> b(n, k, n):
seq(seq(T(n, k), k=0..n*(n-1)), n=1..8); # Alois P. Heinz, Feb 21 2013
Alois P. Heinz, <a href="/A163181/b163181.txt">Rows n = 1..32, flattened</a>
T(n,k) is the number of weak compositions of k into n parts no greater than (n-1) for n>=1, 0<=k<=n(n-1).
T(n,k) is the number of length n sequences on an alphabet of {0,1,2,...,n-1} that have a sum of k. Equivalently T(n,k) is the number of functions f:{1,2,...,n}->{0,1,2,...,n-1} such that Sum(f(i)=k, i=1...n).
Row n is also row n of the array of q-nomial coefficients. [From _- _Matthew Vandermast_, Oct 31 2010]
O.g.f. for row n is ((1-x^n)/(1-x))^n . For k<=(n-1), T(n,k) =Binomial C(n+k-1,k).
T(3,4) = 6 because there are 6 ternary sequences of length three that sum to 4: {[0, 2, 2}, {], [1, 1, 2}, {], [1, 2, 1}, {], [2, 0, 2}, {], [2, 1, 1}, {], [2, 2, 0}].
proposed
editing
editing
proposed
nonn,tabl,tabf,changed
nonn,tabl,changed
proposed
editing
editing
proposed
(*warning very inefficient*) Table[Distribution[Map[Total, Strings[Range[n], n]]], {n, 1, 6}]//Grid (*warning very inefficient*)
Table[Distribution[Map[Total, Strings[Range[n], n]]], {n, 1, 6}]//Grid (*warning very inefficient*)
nn=100; Table[CoefficientList[Series[Sum[x^i, {i, 0, n-1}]^n, {x, 0, nn}], x], {n, 1, 10}]//Grid (* Geoffrey Critzer, Feb 21 2013*)
approved
editing