MethodMath
ET
May 8, 2026

How to compute combinations with repetitions (stars and bars)?

I am studying combinatorics and I understand the basic combinations formula C(n,k)=(nk)C(n, k) = \binom{n}{k} for choosing kk items from nn distinct items without repetition.

But I am confused about combinations with repetition (also called multisets). The formula is:

(n+k1k)\binom{n + k - 1}{k}

where nn is the number of types and kk is the number of items chosen.

Can someone explain:

  1. Why the formula is (n+k1k)\binom{n+k-1}{k} using the stars and bars analogy?
  2. How to apply it to: "How many ways to buy 10 donuts if there are 5 flavors available?"
  3. What about the equation x1+x2+x3+x4=15x_1 + x_2 + x_3 + x_4 = 15 with xi0x_i \geq 0? How many non-negative integer solutions?
  4. What changes if xi1x_i \geq 1 (positive solutions)?
1 answers286 views
Loading comments...

1 Answer

DS
Dr. Sarah MitchellMay 9, 2026 Accepted
**Stars and Bars Explanation:** We want to choose $k$ identical items from $n$ types, allowing repetition. Represent the $k$ items as stars ($*$), and use $n-1$ bars ($|$) to separate the $n$ types. For example, choosing 10 donuts from 5 flavors: arrange 10 stars and 4 bars in a row. The number of stars before the first bar = number of flavor 1 donuts, between bar 1 and 2 = flavor 2, etc. Total arrangements = $\binom{10 + 5 - 1}{10} = \binom{14}{10} = 1001$. **General Formula:** $$\binom{k + n - 1}{k} = \binom{k + n - 1}{n - 1}$$ **Applying to Equations:** For $x_1 + x_2 + x_3 + x_4 = 15$ with $x_i \geq 0$: - $n = 4$ types, $k = 15$ items - Solutions: $\binom{15 + 4 - 1}{15} = \binom{18}{3} = 816$ For **positive** solutions $x_i \geq 1$: Let $y_i = x_i - 1 \geq 0$. Then $y_1 + y_2 + y_3 + y_4 = 15 - 4 = 11$. Solutions: $\binom{11 + 4 - 1}{11} = \binom{14}{3} = 364$ **Key Insight:** The stars and bars method converts combinatorial selection with repetition into counting arrangements of identical objects and dividers. This is one of the most powerful tools in combinatorics.
Loading comments...
Login or Register to post an answer