MethodMath
Ask
Join
HomeTopicsAskAlerts
Profile

© 2026 MethodMath. Built for mathematical knowledge sharing.

AboutContactGuidelinesPrivacyTermsCookies
Emily Thompson
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}C(n,k)=(kn​) for choosing kkk items from nnn distinct items without repetition.

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

(n+k−1k)\binom{n + k - 1}{k}(kn+k−1​)

where nnn is the number of types and kkk is the number of items chosen.

Can someone explain:

  1. Why the formula is (n+k−1k)\binom{n+k-1}{k}(kn+k−1​) 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 = 15x1​+x2​+x3​+x4​=15 with xi≥0x_i \geq 0xi​≥0? How many non-negative integer solutions?
  4. What changes if xi≥1x_i \geq 1xi​≥1 (positive solutions)?
1 answers609 views

1 Answer

3
Sarah Mitchell
May 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.
1 comment
James ChenMay 9, 2026

Stars and bars finally makes sense! The donut analogy is perfect.

Still unsure? Join to comment or ask a follow-up.
Login or Register to post your answer

Suggested questions

Why does 0 factorial equal 1 instead of 0? Simple proof

31.4k

Can someone explain Hilbert's hotel paradox simply?

24k

How many squares are actually in an 8 by 8 chessboard?

22.2k

Does the Banach-Steinhaus theorem hold for non-complete normed spaces?

31.1k

Do I need Calculus 3 before learning Fourier series?

3500