Combinations with Repetition Calculator
How many ways to choose r items from n types when you may take the same type more than once and order does not matter — the doughnut-box problem.
Choosing a dozen doughnuts from six varieties is not C(6, 12) — you can repeat, and there are more than six choices.
How the combinations with repetition calculator works
Choosing a dozen doughnuts from six varieties is not C(6, 12) — you can repeat, and there are more than six choices. The trick, called stars and bars, is to line up r stars and n − 1 dividers: every arrangement is one selection, so the count is C(n + r − 1, r).
This is the standard model for distributing identical objects into distinct boxes.
Formula: C(n + r − 1, r) = (n + r − 1)! / (r! (n − 1)!)
Worked examples
| Inputs | Selections with repetition | Note |
|---|---|---|
| A dozen doughnuts from 6 varieties | 6,188 | 6,188 |
| 3 scoops from 10 flavours | 220 | 220 |
| 5 dice — how many distinct results? | 252 | 252 |
FAQFrequently asked questions
What is the doughnut problem?
Choosing a dozen doughnuts from six varieties. Repeats are allowed and the box order does not matter, so the answer is C(17, 12) = 6,188.
What is stars and bars?
A way of turning the problem into a plain combination: r stars for the items and n − 1 bars to split them between types.
How is this different from nCr?
nCr forbids repeats, so it needs r ≤ n. This version allows any r.
What if I need at least one of each?
Give one of each away first, then distribute the remainder: C(r − 1, n − 1).
Where else does this appear?
Anywhere identical things go into distinct bins — allocating budget across departments, counting monomials, distributing sweets.
Where these figures come from
- NIST Digital Library of Mathematical Functions — reference definitions for elementary and special functions
- Wolfram MathWorld — definitions and formulas for every topic on this page
- NIST/SEMATECH e-Handbook of Statistical Methods — the statistical formulas (mean, variance, z, confidence intervals, sample size)
- Australian Curriculum (ACARA) — Mathematics — the terms and methods taught in Australian schools
Last checked: September 2026. Formulas are fixed by mathematics and do not change with tax years or regulations.