Roll a single 6 faced dice as many times as you want to reach a sum X

863 Views Asked by At

I am working on a problem where a single dice with 6 face is rolled multiple times to reach a sum of X. This is a combinatorics problem. For example if I just want to find out the number of way a sum of 5 has to be obtained (not including negative numbers) the answer would be (2^4) = 16. Basically it follows the formula 2^(X-1) where X is the sum.

But the above formula is valid when there are the restrictions on the numbers that can be used. In my specific case I have the restriction of a six faced dice (numbers from 1 to 6).

What should be my approach to solve this problem?

1

There are 1 best solutions below

2
On

The generating function for the sum of $n$ rolls is $(x+x^2+x^3+x^4+x^5+x^6)^n$ so you can sum the coefficient of $x^X$ in this from $\lceil \frac X6 \rceil$ to $X$. Doing this in Excel is pretty quick if you want a numeric answer. I find the series to be $$1,2,4,8,16,32,63,125,248,492,976,1936,3840,7617,15109,29970,59448,117920,233904,463968,920319,1825529,3621088,7182728,14247536,28261168,56058368,111196417,220567305,437513522,867844316,\ldots$$ These are the Hexanacci numbers, series A001592 in OIES where it says you can get the numbers (with an offset) as coefficients of $\frac {x^5}{1-x-x^2-x^3-x^4-x^5-x^6}$