QED
Combinatorics · step 6 of 13

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.

  1. Identify n and kn is the number of identical items, k the number of distinct boxes or variables.
  2. Apply the formulaC(n + k − 1, k − 1) for non-negative solutions.
  3. 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).
  4. 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?

  1. n = 10 items, k = 3 variables, so C(10 + 3 − 1, 3 − 1) = C(12, 2).
  2. = (12 × 11)/2 = 66.
  3. For xᵢ ≥ 1, first give each variable 1, leaving 7 to distribute freely.
  4. 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.

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.

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 →