Combinations with repetition — also called multiset coefficients — answer the question: “In how many ways can I choose r items from n types when the same type may be picked more than once and the order of picking does not matter?” The answer comes from one of combinatorics’ most elegant results: the stars-and-bars theorem.
How it works
The formula is:
C(n+r−1, r) = (n+r−1)! ÷ (r! × (n−1)!)
where n is the number of distinct item types available and r is the size of the selection you want to make. The trick is to reduce the problem to a standard binomial coefficient by imagining an expanded pool of n+r−1 positions.
Stars-and-bars derivation
Picture r identical stars (one per item chosen) and n−1 vertical bars (the dividers between the n types). Every way to arrange these n+r−1 symbols in a row corresponds to exactly one multiset selection: the number of stars between bars 0 and 1 says how many of type 1 you picked, between bars 1 and 2 how many of type 2, and so on.
Counting the arrangements is simply choosing which r of the n+r−1 positions hold stars — that is, the standard combination C(n+r−1, r). No stars in a gap means zero of that type, which is perfectly legal, so repetition is fully captured.
Worked example
Scenario: An ice-cream shop offers 5 flavours. You order 3 scoops — any flavour can appear more than once (e.g. triple chocolate is allowed). How many distinct orders exist (ignoring the order in which scoops are placed on the cone)?
- n = 5 (flavours), r = 3 (scoops)
- m = n + r − 1 = 5 + 3 − 1 = 7
- Answer = C(7, 3) = 7! ÷ (3! × 4!) = 5040 ÷ (6 × 24) = 35
| n (types) | r (choices) | C(n+r−1, r) | Standard C(n, r) |
|---|---|---|---|
| 5 | 3 | 35 | 10 |
| 4 | 2 | 10 | 6 |
| 3 | 10 | 66 | n/a (r > n) |
| 10 | 5 | 2002 | 252 |
Notice how allowing repetition always produces a larger (or equal) count, and that repetition makes it valid for r to exceed n — something impossible in the standard case.
Formula note
The formula C(n+r−1, r) is sometimes written with the multiset notation ⟨n r⟩ or ((n, r)) to distinguish it from the standard C(n, r). In generating-function terms, it is the coefficient of x^r in the expansion of 1/(1−x)^n. In number theory, it counts the number of non-negative integer solutions to x₁ + x₂ + … + xₙ = r. All three perspectives are equivalent.
This calculator uses exact BigInt arithmetic, so the result is always a precise integer — there is no floating-point rounding even for very large n and r. Results with dozens or hundreds of digits are displayed correctly.