Combinations with Replacement Calculator (CR)
Calculate CR(n,r) = C(n+r−1,r), the number of unordered selections of r items from n types with repeats allowed, via stars and bars, steps shown.
How to use this calculator
Enter n (how many types are available) and r (how many items you are choosing). The calculator returns CR(n, r) — the number of unordered selections where repetition is allowed — along with the stars-and-bars mapping to an ordinary combination and a full step-by-step breakdown.
Repetition is allowed — the key difference from nCr
An ordinary combination assumes each item is chosen at most once, so can never exceed . Combinations with replacement drop that rule: you can pick the same type more than once, and order still doesn't matter. That's exactly how ordering ice cream works — nobody stops you from getting two scoops of the same flavor.
Worked example — CR(5,3)
There are 35 different ways to choose 3 scoops of ice cream from 5 flavors when repeats are allowed and the order you pick them in doesn't matter.
Stars and bars: why CR(n,r) = C(n+r−1,r)
Picture the r items you're choosing as r identical stars, and use n − 1 bars to split them into n groups — one group per type. For CR(5,3), that's 3 stars and 4 bars laid out in a row, e.g. ★★|★||| means "2 of type 1, 1 of type 2, 0 of the rest." Every distinct arrangement of the 7 symbols (3 stars + 4 bars) corresponds to exactly one selection — and choosing which 3 of the 7 positions are stars is just an ordinary combination: . That's the whole trick: replacement turns the counting problem into "how many ways to place bars among stars," which is a standard combination.
The four ways to sample r items from n
Whether repetition and order matter both change the counting formula. There are exactly four combinations:
| Order matters | Order doesn't matter | |
|---|---|---|
| Without replacement | Permutation: | Combination: |
| With replacement |
This calculator handles the bottom-right cell — order doesn't matter and repetition is allowed. It's the only one of the four (besides permutations with replacement) where r is free to exceed n, since you're never running out of types to reuse.
Common examples
- 3 scoops from 5 ice cream flavors, repeats allowed: .
- 3 pieces of fruit from 4 types at a market, repeats allowed: .
- 2 toppings from 3 options, doubling up allowed: .
All three share the same shape: an unordered selection where a type can be picked more than once, mapped onto an ordinary combination via stars and bars.
Frequently asked questions
- What is CR(5,3) and why does it equal C(7,3)?
- CR(5,3) counts the unordered selections of 3 items from 5 types, repeats allowed. The stars-and-bars method maps this onto an ordinary combination: , so .
- What does 'combinations with replacement' mean?
- It means you're choosing r items from n types where order doesn't matter and the same type can be picked more than once — like choosing 3 scoops of ice cream from 5 flavors, where you're allowed to pick the same flavor twice.
- How is this different from a regular combination (nCr)?
- A regular combination assumes each item can only be chosen once, so can never exceed . Combinations with replacement drop that restriction: any type can repeat, so is free to be larger than — 10 scoops from only 3 flavors is still a valid selection.
- What is the stars-and-bars method?
- Stars and bars represents a selection as r identical stars (the items) separated by n − 1 bars into n groups (the types). Every arrangement of the n + r − 1 symbols, choosing which r positions are stars, corresponds to exactly one selection with replacement — which is why .
- Why is CR(n,r) equal to C(n+r−1,r)?
- Because the stars-and-bars arrangement has n + r − 1 total symbol positions, and choosing which r of them are stars (rather than bars) fully determines the selection — that's an ordinary unordered choice of r positions from n + r − 1, i.e. .
- What is a real-world example of combinations with replacement?
- Choosing r scoops of ice cream from n flavors (repeats allowed), picking r pieces of fruit from n types at a market, or choosing r toppings from n options where you can double up on one — all count as .
- What is CR(n,0)?
- Choosing 0 items has exactly one outcome — the empty selection — so for any . This matches the formula: .