<s>[INST] Finding a coefficient using generating functions I need to find a coefficient of $x^{21}$ inside the following expression:
$$(x^{2} + x^{3} + x^{4} + x^{5} + x^{6})^{8}$$
I think the only way (using generating functions) is to express the parentheses content with a generating function.
The generating function for the $(1, x, x^{2}, x^{3}, ...)$ sequence is equal to $\frac{1}{1-x}$.
However, well...the expression at the top is not infinite, so I can't really express it as a generating function.
How can I do this?
 [/INST] $(x^{2} + x^{3} + x^{4} + x^{5} + x^{6})^{8} = x^{16}(1+x+x^2+x^3+x^4)^8$, so you should find the coefficient of $x^5$ in $(1+x+x^2+x^3+x^4)^8$. If you write $5$ as sum of $8$ terms $4\geq k_i\geq 0$ in all possible ways, you'll to see  in how many ways you can get $x^5$. It is also known what is the number of sums of $k$ nonegative terms which sum up in $n$: $n+k-1 \choose k-1$. In your case, there are $8$ sums $5=0+0+...+5=0+...+0+5+0=...=5+0+..+0$,which you cannot get in the products, because $k_i\leq 4$. So the answer is ${5+8-1} \choose{8-1}$$-8$.
</s>