MathOverflow will be down for maintenance for approximately 3 hours, starting Monday evening (06/24/2013) at approximately 9:00 PM Eastern time (UTC-4).

## Deriving a closed form for rolling a sum $n$ with $k$ dice using stars and bars [closed]

I am trying to derive a closed form for computing the number possible outcomes of rolling $k$ dices such that the sum is $n$.

This seems to be the problem of finding number of positive integral solution of an equation $$x_1+x_2+\cdots+x_k=n$$ with $x_1,x_2,\cdots,x_n \in [1,6]$,but here a solution $(a,a,a,a,\cdots \text { k-times} )$ is not considered different.

Direct application of stars and bars gives a closed form $\binom{n-1}{2} \times k \binom{n-7}{2}$ but this is not working for all the cases, For example the case of $n=16$ and $k=3$,what exactly should I modify in my approach?

-
A much better fit for m.se. – Gerry Myerson Oct 24 2011 at 21:19
The definition of "different" is incomprehensible. Difference is a binary relation. State precisely when two dice roles are considered the same. – Brendan McKay Oct 25 2011 at 0:43
One problem with directing this question to Math.StackExchange is that it has been asked there before but most of the answers have been wrong or misleading. – Douglas Zare Oct 25 2011 at 8:49
@Douglas Zare:That is the reason I posted it here,I see it is closed now,but I guess I got my answer :) – unknown (google) Oct 25 2011 at 13:46

## closed as off topic by Qiaochu Yuan, Todd Trimble, Gerry Myerson, Kevin Walker, S. Carnahan♦Oct 25 2011 at 9:02

Answer is given by the coefficient of $z^n$ in $$(z+z^2+\dots+z^6)^k = \left(z\frac{1-z^6}{1-z}\right)^k = z^k (1-z^6)^k(1-z)^{-k}.$$ An explicit formula for this coefficient is: $$\sum_{i=0}^{\min(k,\lfloor (n-k)/6\rfloor)} (-1)^{n+i} \binom{k}{i} \binom{-k}{n-k-6i} = \sum_{i=0}^{\min(k,\lfloor (n-k)/6\rfloor)} (-1)^i \binom{k}{i} \binom{n-6i-1}{k-1}.$$