Stars and bars with restriction of size between bars via generating functions. I would like to know a way to solve the problem. How can we divide n identical marbles into k distinct with each pile having at most w marbles. I have seen a solution due to Brian Scott on the problem using inclusion-exclusion but I would like one via generating functions. In particular how can i solve with $n=30,k=10$ and $w=4$??
 A: The choice in each pile can be represented as $(1+x+x^2+x^3+x^4)$, corresponding to no marbles, 1 marble etc. all the way to 4 marbles.  As there are $10$ piles, we have the possibilities equal to the coefficient of $x^{30}$ in $(1+x+x^2+x^3+x^4)^{10}$ - corresponding to each arrangement of the piles, there will be a contribution to the coefficient of $x^{30}$ from some one term in each of the factors.
Now we can expand that out and find the result, or note that $1-x^5 = (1-x)(1+x+x^2+x^3+x^4)$, so we are searching for the same coefficient in the series expansion of $\dfrac{(1-x^5)^{10}}{(1-x)^{10}}$, which may be simpler to compute as the product of two sums below:
$$(1-x^5)^{10} = \sum_{k=0}^{10} \binom{10}{k}(-1)^k x^{5k} = 1-10 x^5+45 x^{10}-120 x^{15}+210 x^{20}-252 x^{25}+210 x^{30}-120 x^{35}+45 x^{40}-10 x^{45}+x^{50} $$
Of these, only the first $7$ terms can contribute to the coefficient of $x^{30}$.  
$$(1-x)^{-10} = \sum_{k=0}^{\infty} \binom{-10}{k}(-1)^k x^{k} = 1+\frac{10}{1!}x+\frac{10\cdot 11}{2!}x^2+...\frac{10\cdot 11\cdot 12\cdot13\cdot14}{5!}x^5+... $$
Note that we need only the terms of degree $5k$ in the second series.  Cross multiplying the terms which contribute to $x^{30}$ you have your answer.
