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
 A: It is the coefficient of $x^{25}$ in the expression $(x+x^2+x^3+x^4+x^5+x^6)^5$. Which is $\color{red}{126}$.
A: 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. $$
A: In addition to my other answer using generating functions, I want to offer a more elementary solution. First note that
$$ 5 + 5 + 5 + 5 + 5 = 25 $$
and this is the only way to make $25$ without using a $6$.
Now make one of the dice a $6$ (5 possible ways) to get the equation
$$ a + b + c + d = 19 $$
where $1 \le a, b, c, d \le 19$. Again, the best you can do without a $6$ is
$$4 + 5 + 5 + 5 = 19$$
and there are $4$ of these (one for each position of the $4$.
Now remove a second $6$ to get the equation
$$ a + b + c = 13. $$
Without $6$'s this has two solutions:
$$ 3 + 5 + 5 = 13, $$
which occurs three times, and
$$ 4 + 4 + 5, $$
which also occurs three times.
Remove three $6$'s to get
$$ a + b = 7 $$
which has $4$ solutions not involving a $6$.
Finally remove four $6$'s to get
$a = 1$
with exactly one solution.
Hence in total we have
$$ \binom{5}{0}1 + \binom{5}{1} 4 + \binom{5}{2} 6 + \binom{5}{3} 4 + \binom{5}{4} = 126. $$
The binomial coefficients indicate how many $6$'s we have.
A: I've got a rather non-mathematical solution. First, simplify
$$x_{1}+x_{2}+x_{3}+x_{4}+x_{5} = 25,\quad 1 \le x_i \le 6$$
using $y_i = x_i -1$ to
$$y_{1}+y_{2}+y_{3}+y_{4}+y_{5} = 20,\quad 0 \le y_i \le 5$$
and (just like the top answer) use the dual $z_i = 5 - y_i$ to get
$$z_{1}+z_{2}+z_{3}+z_{4}+z_{5} = 5,\quad 0 \le z_i \le 5$$
Note that I could drop the upper bound, but I don't care.
Let $f(i, n)$ be the number of possibilities how to obtain $n$ as sum of $i$ variables in to the range $0..5$. Obviously, for every $0 \le n \le 5$
$$f(1, n) = 1$$
$$f(2, n) = \sum_{j=0}^n\ f(1, n) \cdot f(1, n) = n+1$$
$$f(3, n) = \sum_{j=0}^n\ f(1, n) \cdot f(2, n) = \sum_{j=0}^n\ n+1 = \frac{(n+1)(n+2)}2$$
$$f(5, n) = \sum_{j=0}^n\ f(2, n) \cdot f(3, n)$$
Let $s(i)$ denote the sequence $f(i, 0), \dots, f(i, 5)$
$$s(1) = 1, 1, 1, 1, 1, 1$$
$$s(2) = 1, 2, 3, 4, 5, 6$$
$$s(3) = 1, 3, 6, 10, 15, 21$$
and compute the result as
$$1\cdot21 + 2\cdot15 + 3\cdot10 + 4\cdot6 + 5\cdot3 + 6\cdot1 = 126$$
Falling back to such a computation feels very non-mathematical (I could compute the sum symbolically, but I chose not to), but it's useful in case no closed form expression can be found or gets too complicated (just add some crazy condition and you're there). When this happens, then after some simplifications, the computer is your friend.
