Combinatorics – Number of Ways to Distribute n Identical Balls into k Identical Boxes

balls-in-binscombinationscombinatoricsinteger-partitions

I wonder how to count the number of ways (algorithmically is fine) to distribute $n$ identical balls into $k$ identical boxes such that no box contains more than $m$ balls?

I've run into answers in which either the balls are non-identical or the boxes are non-identical, but not this version.

Best Answer

This type of questions can be solved using Gaussian binomial coefficient.When we look at the its combinatorial usage , we can see that "Let $B(n,m,r)$ be the number of ways of throwing $r$ indistinguishable balls into $m$ indistinguishable bins, where each bin can contain up to $n$ balls. The Gaussian binomial coefficient can be used to characterize $B(n,m,r)$."

$$B(n,m,r)=[q^r]\binom{n+m}{m}_q$$ where $[q^r]P$ denotes the coefficient of $q^r$ in polynomial $P$