Chris Phan's comment sounds right to me, but you may be able to do this more quickly, though OEIS doesn't seem to have any details on rows or columns of the below array except that they're (at least often) multinomial coefficients. I have computed these numbers in MATLAB using [this stuff][1]: >> for n=1:8,for k=1:9,L=lookup(k,n);L1(k,n)=sum(sum((L==1),2)>0);end,end,L1 L1 = 1 0 0 0 0 0 0 0 2 1 2 2 2 2 2 2 3 3 7 9 12 15 18 21 4 6 16 25 40 58 80 106 5 10 30 55 101 165 255 375 6 15 50 105 216 391 666 1071 7 21 77 182 413 819 1520 2646 8 28 112 294 728 1568 3144 5881 9 36 156 450 1206 2802 6030 12051 ---------- As an example, consider k=4 and n=3: MATLAB gives (I have added asterices for clarity) >> lookup(4,3) ans = 0 0 0 3 0 0 1 2 * 0 0 2 1 * 0 0 3 0 0 1 0 2 * 0 1 1 1 * 0 1 2 0 * 0 2 0 1 * 0 2 1 0 * 0 3 0 0 1 0 0 2 * 1 0 1 1 * 1 0 2 0 * 1 1 0 1 * 1 1 1 0 * 1 2 0 0 * 2 0 0 1 * 2 0 1 0 * 2 1 0 0 * 3 0 0 0 and visual inspection shows that the number of rows with at least one unit entry is 16, identical with the table entry. [1]: https://mathoverflow.net/questions/9477/uniquely-generate-all-permutations-of-three-digits-that-sum-to-a-particular-value/9482#9482