Finding the coefficient of a term of a specific power after polynomial exponentiation? I'm trying to write a probability function involving a 5-sided dice that has face values 2-5.  I need to find the probability that the sum of n rolls of the dice equals k.  I know I can find this through the coefficient of the x^k term after evaluating the following expression:
$$\prod_{k=1}^n(x^2+x^3+x^4+x^5+x^6)\ $$
I'd like to not have to search through the terms manually. Is there a different expression that can simply produce the coefficient value?
 A: In order to obtain the coefficient it is convenient to use the coefficient of operator $[x^k]$ to denote the coefficient of $x^k$ in a series.

We obtain for $k\geq 2n$
  \begin{align*}
\color{blue}{[x^{k}]}&\color{blue}{(x^2+x^3+x^4+x^5+x^6)^n}\\
&=[x^{k}]x^{2n}(1+x+x^2+x^3+x^4)^n\tag{1}\\
&=[x^{k-2n}]\frac{(1-x^5)^n}{(1-x)^n}\tag{2}\\
&=[x^{k-2n}]\sum_{j=0}^n\binom{n}{j}(-x^{5j})\sum_{l=0}^\infty\binom{-n}{l}(-x)^l\tag{3}\\
&=\sum_{j=0}^n\binom{n}{j}(-1)^j[x^{k-2n-5j}]\sum_{l=0}^\infty\binom{n+l-1}{l}x^l\tag{4}\\
&\color{blue}{=\sum_{j=0}^{\lfloor\frac{k-2n}{5}\rfloor}\binom{n}{j}\binom{k-n-5j-1}{k-2n-5j}(-1)^j}\tag{5}
\end{align*}

Comment:


*

*In (1) we factor out $x^{2n}$.

*In (2) we apply the rule $[x^{p-q}]A(x)=[x^p]x^qA(x)$ and use the finite geometric series formula.

*In (3) we expand the numerator  using the binomial theorem. We also apply the binomial series expansion.

*In (4) we use the linearity of the  coefficient of operator and apply the same rule as in (2). We also apply the binomial identity
\begin{align*}
\binom{-p}{q}=\binom{p+q-1}{q}(-1)^q
\end{align*}.

*In (5) we select the coefficient accordingly and restrict the upper limit of the sum since the exponent $k-2n-5j$ of $x$ has to be non-negative.
