# How many ways to roll n with any number of dice

For example, if I want to roll n=6,

with 1 die it can be thrown in $$\binom {5} {0} = 1$$ way, with 2 dice $$\binom {5} {1} = 5$$ 3 dice $$\binom {5} {2} = 10$$ 4 dice $$\binom {5} {3} = 10$$ 5 dice $$\binom {5} {4} = 5$$ 6 dice $$\binom {5} {5} = 1$$ The sum of these is 32 - the correct answer, I believe.

I thought that the answer for any number n (where the number of dice is d) is $$\sum_{d=1}^{d=n} \binom {n-1} {d-1}$$ It seems that this isn't working, though. For example the correct answer for n=8 is 125, but this equation gives me 128. Where am I going wrong? Thanks in advance.

• Hi Kurns, what are you actually counting with ${{n-1} \choose {d-1}}$? – 57Jimmy Jan 5 '18 at 8:40
• The number of ways the number n can be rolled with d dice. – Kurns Jan 5 '18 at 8:42
• Sure, but why can one compute it that way? What are you really counting? – 57Jimmy Jan 5 '18 at 10:04
• I read that online... and it seems to work, to a point at least – Kurns Jan 5 '18 at 10:14
• Though $\binom{7}{0}=1$, you cannot roll an 8 with one die, and though $\binom{7}{1} = 7$ there are only 5 ways to roll an 8 with two dice. – Fabio Somenzi Jan 5 '18 at 10:15

The answer is surprisingly complicated. The number of ways to roll $n$ with $m$ die is the coefficient of $x^n$ in the generating function
$$(x + x^2 + \dots + x^6)^m = x^m \left( \frac{1 - x^6}{1 - x} \right)^m.$$
This can be simplified somewhat but not substantially by applying the binomial theorem to $(1 - x^6)^m$ and $\frac{1}{(1 - x)^m}$ (here you will need the binomial theorem with negative exponents).