Counting with repetition (stars & bars)
Stars and bars counts the ways to distribute n identical items into k distinct boxes: represent the items as n stars and the box dividers as k−1 bars, and every arrangement of the n + k − 1 symbols gives a distribution. So the count is C(n + k − 1, k − 1) — and this equals the number of non-negative integer solutions of x₁ + … + x_k = n.
✓ Unlimited questions · marked criterion by criterion · no card needed
Method: how to approach it
The order below is what examiners expect to see, and each step carries its own marks.
- Identify n and kn is the number of identical items, k the number of distinct boxes or variables.
- Apply the formulaC(n + k − 1, k − 1) for non-negative solutions.
- Handle a positivity requirement by pre-assigningFor xᵢ ≥ 1, give each box one item first, then distribute the remaining n − k, giving C(n − 1, k − 1).
- Handle upper bounds with inclusion–exclusionSubtract the distributions violating each bound, then correct for double violations.
Worked example
How many non-negative integer solutions does x + y + z = 10 have? And how many with all variables at least 1?
- n = 10 items, k = 3 variables, so C(10 + 3 − 1, 3 − 1) = C(12, 2).
- = (12 × 11)/2 = 66.
- For xᵢ ≥ 1, first give each variable 1, leaving 7 to distribute freely.
- C(7 + 3 − 1, 2) = C(9,2) = 36.
Answer. 66 non-negative solutions; 36 with all variables strictly positive.
Where marks get dropped
These are the specific errors that cost credit on counting with repetition (stars & bars) questions — QED's rubric penalises each of them separately.
- Using C(n + k − 1, k) instead of C(n + k − 1, k − 1). The bars number k − 1, not k.
- Applying the method to DISTINCT items. Stars and bars requires the items to be identical; distinct items into distinct boxes is kⁿ.
- Ignoring upper bounds. If a variable is capped, the raw formula overcounts and needs inclusion–exclusion.
Practise this until it is automatic
Unlimited fresh questions
QED generates new counting with repetition (stars & bars) problems on demand at warm-up, exam and challenge level, so you can drill this one skill until it stops costing you marks.
Marked like an examiner
Every answer is scored against a point-by-point rubric with partial credit, so you see exactly which step of the method broke down — not just a tick or a cross.
Answer in real notation
A one-tap symbol palette, a visual equation editor and a truth-table builder — or photograph your handwritten working and QED converts it to LaTeX.
Saved to your library
Every question you generate is kept and re-takeable as a timed exam, and your Combinatorics mastery is tracked so you know when this is exam-ready.
Counting with repetition (stars & bars) — frequently asked questions
Why does the formula work?
Every distribution corresponds uniquely to an arrangement of n stars and k−1 bars in a row. Choosing the bar positions among the n + k − 1 slots gives the count.
What if items are distinct?
Then each item independently chooses a box, giving kⁿ. Stars and bars would badly undercount.
How do I handle x₁ ≥ 2 and x₂ ≥ 3?
Pre-assign 2 and 3, reducing n by 5, then apply the standard formula to what remains.
The rest of Combinatorics
Counting principles, permutations, combinations. Each subtopic below has its own method, worked example and mark-losing traps.
- 1Sum & product rules
- 2Permutations & combinations
- 3Binomial theorem & Pascal’s triangle
- 4The pigeonhole principle
- 5Inclusion–exclusion
- 6Counting with repetition (stars & bars)
- 7Derangements & counting surjections
- 8Double counting & bijective proofs
- 9Setting up & solving counting recurrences
- 10Generating functions — an introduction
- 11Multinomial coefficients & repeated items
- 12Hockey stick & Vandermonde identities
- 13Catalan numbers & lattice-path counting
Ready to make counting with repetition (stars & bars) exam-proof?
Generate your first questions free — no card, no setup, no personal data stored. Practise until the method is second nature.
Start practising free →