# Number of ways of distributing $N$ similar objects among $R$ baskets with limit on each basket capacity

The basic one, number of ways of distributing $N$ objects among $R$ baskets without any limit has a general formula $C(N + R -1, R -1 )$. But here there is limit on each basket capacity , like example

$$x_1 + x_2 + x_3 + x_4 .... = N$$

with $0 \leq x_1 \leq k_1$, $0 \leq x_2 \leq k_2$, $0 \leq x_3 \leq k_3$, $0 \leq x_4 \leq k_4$. Here $k_1,k_2,k_3,k_4$ can be anything less than $N$ and each has a different value. I am unable to figure it out. Someone please help me in this.

• Did you mean $x_1 + x_2 + x_3 + x_4 + \cdots + x_R = N$? Also, please read this tutorial on how to typeset mathematics on this site. – N. F. Taussig Oct 27 '15 at 20:56
• You could use generating functions: consider the product $(1+x+\ldots + x^{k_1})(1+x+\ldots + x^{k_2})(1+x+\ldots + x^{k_3})(1+x+\ldots+x^{k_4})$. You want the coefficient of $x^N$. – Henno Brandsma Oct 27 '15 at 21:34