Roll a 6 sided die $n$ times, what is the probability that the sum of the $n$ rolls gives $s$? I am wondering if there is a closed form solution for the problem. I can solve it using dynamic programming, but couldn't come up with anything analytically.
Here is my thought process. Suppose that after $n$ rolls we have reached the target sum $s$. If $s >= 6$, the n-th roll must be 1,2,3,4,5,6. So then we can count the number of ways to get sum $s-1, s-2, \ldots, s-6$ with $n-1$ rolls. And so on. So it seems we can apply the law of total probability here. Another idea I was thinking could be using Markov chains. But both of these methods seem like it would take a lot of work.
Is there a simpler solution to this problem?
 A: One can derive the closed form expression using the generating function approach suggested in the previous answer as follows:
$$
\left(\sum_{i=1}^6 x^i\right)^n=x^n\left(\sum_{i=0}^5 x^i\right)^n
=x^n\left(\frac{1-x^6}{1-x}\right)^n
=x^n\sum_{i=0}^n\binom ni(-x^6)^i\sum_{j=0}^\infty\binom{-n}j(-x)^j.
$$
Thus, the number of ways to obtain the sum $s$ after $n$ throws is
$$\begin{align}
W(n,s)=[x^s]\left(\sum_{i=1}^6 x^i\right)^n
&=[x^{s-n}]\sum_{i=0}^n\sum_{j=0}^\infty(-1)^i\binom ni\binom{n+j-1}{n-1}x^{6i+j}\\
&=\sum_{i=0}^{\left\lfloor\frac{s-1}6\right\rfloor}(-1)^i\binom ni\binom{s-6i-1}{n-1},
\end{align}$$
where $[x^r]$ is the coefficient extractor function which gives the coefficient at $x^r$ in the series expansion of the following expression.
Hence the corresponding probability is:
$$
p(n,s)=\frac1{6^n}\sum_{i=0}^{\left\lfloor\frac{s-1}6\right\rfloor}(-1)^i\binom ni\binom{s-6i-1}{n-1}.
$$
The same result can be also obtained using inclusion-exclusion principle.
A: Idea: (need not be simple though)
Here is a way to find the number of ways (and ultimately the probability) in which the $n$ rolls will sum up to (a given) $s$. Using the idea of generating functions consider
$$(x^1+x^2+\dotsb+x^{6})^n \quad \text{ now } \quad \text{find the coefficient of } x^s$$
