<s>[INST] In how many ways the sum of 5 thrown dice is 25? What I thought about is looking for the number of solutions to
$$x_{1}+x_{2}+x_{3}+x_{4}+x_{5}=25$$ such that $1\leq x_{i}\leq6$
for every $i$.
Now I know that the number of solutions to this such that
$0\leq x_{i}$ for every $i$ is $${5+25-1 \choose 5-1}={29 \choose 4}$$
How can I continue from here?
Thanks
 [/INST] When we multiply polynomials the formula is
$$ \left( \sum_i a_ix^i \right)\left( \sum_j b_jx^j \right) = \sum_k \left( \sum_{i + j = k} a_ib_j \right) x^k. $$
For a product of $5$ polynomials, we have:
$$ \left( \sum_{i_1} a_{1, i_1}x^{i_1} \right)\left( \sum_{i_2} a_{2, i_2}x^{i_2} \right)\left( \sum_{i_3} a_{3, i_3}x^{i_3} \right)\left( \sum_{i_4} a_{4, i_4}x^{i_4} \right)\left( \sum_{i_5} a_{5, i_5}x^{i_5} \right)$$
$$= \sum_k \left( \sum_{i_1 + i_2 + i_3 + i_4 + i_5 = k} a_{1,i_1}a_{2,i_2}a_{3,i_3}a_{4,i_4}a_{5,i_5} \right) x^k. $$
In particular notice the sum is over all solutions to $i_1 + i_2 + i_3 + i_4 + i_5 = k$. Here we want $k = 25$ and we want $a_{1,i_1}a_{2,i_2}a_{3,i_3}a_{4,i_4}a_{5,i_5} = 1$ except when $i_1, i_2, i_3, i_4$ or $i_5$ is $0$ or $> 6$ in which case we want $0$.
Thinking about this for a minute, we know that we want the coefficient on $x^{25}$ in the product
$$ (x + x^2 + x^3 + x^4 + x^5 + x^6)^5. $$
The polynomial $x + x^2 + x^3 + x^4 + x^5 + x^6$ is telling us that each die can be either $1,2,3,4,5$ or $6$ and each number occurs exactly once.
Let $[x^{n}]f(x)$ denote the coefficient of $x^n$ in $f(x)$. Then we have
\begin{align}
[x^{25}](x + x^2 + x^3 + x^4 + x^5 + x^6)^5 &= [x^{25}] \left(\frac{x(1 - x^6)}{1 - x} \right)^5 \\
&= [x^{25}] x^5\left(\frac{1 - x^6}{1 - x} \right)^5 \\
&= [x^{20}] \left(\frac{1 - x^6}{1 - x} \right)^5 \\
&= [x^{20}] (1 - x^6)^5 \frac{1}{(1 - x)^5} \\
&= [x^{20}] \left( \sum_{k = 0}^5 \binom{5}{k} (-1)^kx^{6k} \right) \frac{1}{(1 - x)^5} \\
&= \sum_{k = 0}^5 \binom{5}{k} (-1)^k [x^{20}]x^{6k} \frac{1}{(1 - x)^5} \\
&= \sum_{k = 0}^5 \binom{5}{k} (-1)^k [x^{20 - 6k}] \frac{1}{(1 - x)^5} \\
&= \sum_{k = 0}^3 \binom{5}{k} (-1)^k [x^{20 - 6k}] \frac{1}{(1 - x)^5}
\end{align}
We change the upper limit from $5$ down to $3$ because we need $20 - 6k$ to be $\ge 0$ (equivalently, this says we can only have at most three of the dice equal to $6$). Continuing, we get
$$ \sum_{k = 0}^3 \binom{5}{k} (-1)^k [x^{20 - 6k}] \sum_{j} \binom{5 + j - 1}{j}x^j $$
telling us that $j = 20 - 6k$ and finally this gives us
$$ \sum_{k = 0}^3 \binom{5}{k} (-1)^k \binom{5 + (20 - 6k) - 1}{20 - 6k} = \sum_{k = 0}^3 \binom{5}{k} \binom{24 - 6k}{20 - 6k} (-1)^k = 126. $$
</s>