# What is the probability that the sum of six rolls of a fair die is divisible by $7$?

$$P(E)=\frac{\text{Favourable outcomes}}{\text{Total outcomes}}$$

Total outcomes $$=6^6$$

Favourable outcomes means the sum must be $$7$$, $$14$$, $$21,28$$ or $$35$$

Assume $$a_1$$, $$a_2$$, $$a_3$$, $$a_4$$, $$a_5$$, $$a_6$$ to be the numbers on the top faces of the dice

In case of $$7$$ and $$35$$ the number of cases should be $$6$$ as $$0.

When the sum is $$14$$, favourable outcomes are: $${14 \choose 6}-6\left({7 \choose5}+{6 \choose 5}+1\right).$$ I tried this by a variation of beggars method. Let's assume there are $$14$$ coins, and $$6$$ beggars. There are $$14$$ places for the beggars to choose, such that there are $$13$$ places between two coins and one to the left of the first coin. Each beggar gets all the coins between himself and the beggar just to the right of him. This way we ensure that each beggar at least gets one coin. After this I subtracted the number of cases where one beggar gets more than one coin.

Now this is solvable up to this point, but I'm getting a very large equation when I do this for $$21$$ and $$28$$. Is there a better method, since I will most probably only have $$5$$ min in the upcoming exam on $$3^d$$ October.

• If six pairs of six-faced dice are rolled, then $12$ dice are rolled. Is that what you meant? Sep 28, 2021 at 13:33
• @N.F.Taussig, no thanks for pointing out the mistake Sep 28, 2021 at 13:34
• @N.F.Taussig, I'm sorry I don't understand, 6*6 would be 36 right? Sep 28, 2021 at 13:36
• You are correct. My mind was not working properly. Sep 28, 2021 at 13:37
• I think stars and bars method can be useful here. See this Sep 28, 2021 at 13:45

The number of outcomes with sum $$14$$ is the number of solutions of the equation $$a_1 + a_2 + a_3 + a_4 + a_5 + a_6 = 14 \tag{1}$$ in the positive integers subject to the restrictions that $$a_i \leq 6$$, $$1 \leq i \leq 6$$.

A particular solution Equation 1 in the positive integers corresponds to the placement of $$6 - 1 = 5$$ addition signs in the $$13$$ spaces between successive ones in a row of $$14$$ ones.
$$1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1 \square 1$$ For instance, if we select the second, fifth, seventh, tenth, and twelfth spaces, we get $$1 1 + 1 1 1 + 1 1 + 1 1 1 + 1 1 + 1 1$$ which corresponds to the solution $$a_1 = 2, a_2 = 3, a_3 = 2, a_4 = 3, a_5 = a_6 = 2$$. The number of such solutions is the number of ways we can select which $$6 - 1 = 5$$ of the $$14 - 1 = 13$$ spaces can be filled with an addition sign, which is $$\binom{14 - 1}{6 - 1} = \binom{13}{5}$$

In general, the number of solutions of the equation $$x_1 + x_2 + \cdots + x_k = n$$ in the positive integers is $$\binom{n - 1}{k - 1}$$ since we must select which $$k - 1$$ of the $$n - 1$$ spaces between successive ones in a row with $$n$$ ones will be filled with addition signs.

From these $$\binom{13}{5}$$ solutions in the positive integers, we must subtract those solutions in which one or more of the variables exceeds $$6$$. At most one variable can exceed $$6$$ since $$7 + 7 + 1 + 1 + 1 + 1 = 16 > 14$$.

Suppose $$a_1 > 6$$. Then $$a_1' = a_1 - 6$$ is a positive integer. Substituting $$a_1' + 6$$ for $$a_1$$ in equation 1 yields \begin{align*} a_1' + 6 + a_2 + a_3 + a_4 + a_5 + a_6 & = 14\\ a_1' + a_2 + a_3 + a_4 + a_5 + a_6 & = 8 \tag{2} \end{align*} Equation 2 is an equation in the positive integers with $$\binom{8 - 1}{6 - 1} = \binom{7}{5}$$ solutions.

By symmetry, there are an equal number of cases for each $$a_i$$ which violates the restriction that $$a_i \leq 6$$. Hence, the number of admissible solutions of Equation 1 is $$\binom{13}{5} - \binom{6}{1}\binom{7}{5}$$

To find the number of outcomes with sum $$21$$, we can use the Inclusion-Exclusion Principle. We find the number of solutions of the equation $$a_1 + a_2 + a_3 + a_4 + a_5 + a_6 = 21 \tag{3}$$ in the positive integers subject to the restrictions that $$a_i \leq 6$$, $$1 \leq i \leq 6$$, by first counting the number of solutions of Equation 3 in the positive integers, then subtracting the number of solutions which violate at least one of the restrictions. Note that at most two restrictions may be violated simultaneously since $$7 + 7 + 7 + 1 + 1 + 1 = 24 > 21$$.

If we subtract those cases which violate a restriction, we end up subtracting each case which violates two of the restrictions twice, once for each way of designating one of the violated restrictions as the restriction that has been violated. Therefore, we must add those cases in which two of the restrictions have been violated to the difference of the total number of solutions and the number which violate one of the restrictions.

As you should check, the number of solutions of equation 3 in the positive integers is $$\binom{21 - 1}{6 - 1} = \binom{20}{5}$$ As you should check, the number of solutions which violate one of the restrictions is $$\binom{6}{1}\binom{15 - 1}{6 - 1} = \binom{6}{1}\binom{14}{5}$$ and the number of solutions which violate two of the restrictions is $$\binom{6}{2}\binom{9 - 1}{6 - 1} = \binom{6}{2}\binom{8}{5}$$ Hence, by the Inclusion-Exclusion Principle, the number of ways to obtain a sum of $$21$$ with six dice is $$\binom{20}{5} - \binom{6}{1}\binom{14}{5} + \binom{6}{2}\binom{8}{5}$$

The Inclusion-Exclusion Principle can also be used to solve for the number of solutions of the equation $$a_1 + a_2 + a_3 + a_4 + a_5 + a_6 = 28 \tag{4}$$ in the positive integers subject to the restrictions that $$a_i \leq 6$$, $$1 \leq i \leq 6$$. However, we can use symmetry to avoid that calculation.

Notice that if $$1 \leq a_i \leq 6$$, then $$b_i = 7 - a_i$$ also satisfies the condition that $$1 \leq b_i \leq 6$$. Substituting $$7 - b_i$$ for $$a_i$$, $$1 \leq i \leq 6$$, in Equation 4 yields \begin{align*} 7 - b_1 + 7 - b_2 + 7 - b_3 + 7 - b_4 + 7 - b_5 + 7 - b_6 & = 28\\ -b_1 - b_2 - b_3 - b_4 - b_5 - b_6 & = -14\\ b_1 + b_2 + b_3 + b_4 + b_5 + b_6 & = 14 \tag{5} \end{align*} However, we already calculated the number of solutions of Equation 5 that satisfy the restrictions $$b_i \leq 6$$, $$1 \leq i \leq 6$$ above.

More generally, by symmetry the number of solutions of the equation $$a_1 + a_2 + a_3 + a_4 + a_5 + a_6 = S \tag{6}$$ in the positive integers subject to the restrictions that $$a_i \leq 6$$, $$1 \leq i \leq 6$$, is equal to the number of solutions of the equation $$b_1 + b_2 + b_3 + b_4 + b_5 + b_6 = 42 - S \tag{7}$$ in the positive integers subject to the restrictions that $$b_i \leq 6$$, $$1 \leq i \leq 6$$, which is why you obtained the same number of solutions for the sums $$7$$ and $$35$$.

• Agreed, I just noticed that myself. Therefore, there is no way of avoiding Inclusion-Exclusion, which your answer is already employing. Therefore, I have deleted my answer. Sep 28, 2021 at 14:42

For a second way , you can use generating functions. Lets say that the numbers appears in throwing represented by $$x_1,x_2,x_3,x_4,x_5,x_6$$. So , we are looking for $$7,14,21,28,35$$ as the summation.

Then ,we can say that we are looking for the coefficents for $$[x^n]$$ where $$n$$ is $$7,14,21,28,35$$ , respectively.

It can be seen that the generating function of $$x_1,...,x_6$$ are the same and it is equal to $$\bigg(x\times \frac{1-x^6}{1-x}=\frac{x -x^7}{1-x}\bigg)$$

Then , as all of the generating functions are equal

• Find $$[x^7] \bigg(\frac{x -x^7}{1-x}\bigg)^6$$

• Find $$[x^{14}] \bigg(\frac{x -x^7}{1-x}\bigg)^6$$

• Find $$[x^{21}] \bigg(\frac{x -x^7}{1-x}\bigg)^6$$

• Find $$[x^{28}] \bigg(\frac{x -x^7}{1-x}\bigg)^6$$

• Find $$[x^{35}] \bigg(\frac{x -x^7}{1-x}\bigg)^6$$

We stoped at $$35$$ because it is the maximum value of summation that divided by $$7$$

CALCULATION VIA WOLFRAM-ALPHA

Then , $$\frac{[x^7]+[x^{14}]+[x^{21}]+[x^{28}] +[x^{35}]}{6^6}=\frac{6+1161+4332+1161+6}{6^6}= \frac{6666}{46656}=0,1428755...$$

You can encapsulate the stars-and-bars cum inclusion-exclusion for a desired sum $$s$$ rolling a six-sided die six times, using the formula

$$\text{Number of ways}\;W(s) = \sum_{i=0}^{\lfloor\frac{s-6}{6}\rfloor}(-1)^i\binom{6}{i}\binom{s-1-6i}5$$

• +1 for making the question concise and practical Sep 28, 2021 at 15:25
• Glad you like it, you are going great guns with g.fs ! (+1) Sep 28, 2021 at 17:06