# Combination with repetition/replacement formula

Can someone explain the difference in the formula used for the following combination with repetition/replacement problems?

1) The local Dunkin' Donuts has thirty varieties of donuts. How many distinct ways can a box of a dozen donuts be filled?

The formula used was $\binom{n + r - 1}{r}$ here, and the answer was 12 -combinations of a 30-element set, with repetition/replacement. So $\binom{30+12−1}{12}$=7,898,654,920

2) How many solutions are there in the non-negative integers to the equation: $$x^1+x^2+x^3=11$$

Their solution: This amounts to drawing 11 balls from a bag of red, blue, and yellow balls, and counting the distinct combinations. So, 11 combinations of 3 elements give us $\binom{11+3-1}{11}$ = 78

Why does the formula for the second question have n as the denominator instead of r?

• Perhaps if you rephrase the first question so it reads like the second: How many non-negative integer solution vectors $(x_1,x_2,\ldots,x_{30})$ are there to $$x_1+x_2+x_3+\ldots+x_{30}=12$$ In this case the variable $x_i$ is the number of donuts of flavour $i$ that are in the box (those should be subscripts by the way) and they must, of course, sum to 12. Can you see the link? – N. Shales Mar 12 '17 at 3:45
• The answer to the first question should be $$\binom{30 + 12 - 1}{12} = 7,898,654,920$$ – N. F. Taussig Mar 12 '17 at 10:36

## 1 Answer

Think of your second question as 'The local Dunkin' Donuts has three varieties of donuts. How many distinct ways can a box of a 11 donuts be filled?'

Suppose you are not taking any donuts of variety x1 to fill the bag, then x1 = 0. In total you have to fill 11 donuts in your bag.

Now you can use the same formula to solve this question. Hope this helps!