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.

Loading calculator…

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.

Tip: If your problem forbids picking the same type twice — dealing cards, assigning distinct seats — you want a plain combination (nCr) instead, not this calculator.

Repetition is allowed — the key difference from nCr

An ordinary combination C(n,r)C(n,r) assumes each item is chosen at most once, so rr can never exceed nn. 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.

CR(n,r)=(n+r1r)=C(n+r1,r)CR(n,r) = \binom{n+r-1}{r} = C(n+r-1,\,r)

Worked example — CR(5,3)

CR(5,3)=C(5+31,3)=C(7,3)=7!3!×4!=35CR(5,3) = C(5+3-1,\,3) = C(7,3) = \frac{7!}{3! \times 4!} = 35

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: C(7,3)=35C(7,3) = 35. 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 mattersOrder doesn't matter
Without replacementPermutation: n!/(nr)!n!/(n-r)!Combination: n!/(r!(nr)!)n!/(r!(n-r)!)
With replacementPR(n,r)=nrPR(n,r) = n^rCR(n,r)=(n+r1r)CR(n,r) = \binom{n+r-1}{r}

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: CR(5,3)=C(7,3)=35CR(5,3) = C(7,3) = 35.
  • 3 pieces of fruit from 4 types at a market, repeats allowed: CR(4,3)=C(6,3)=20CR(4,3) = C(6,3) = 20.
  • 2 toppings from 3 options, doubling up allowed: CR(3,2)=C(4,2)=6CR(3,2) = C(4,2) = 6.

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: CR(n,r)=C(n+r1,r)CR(n,r) = C(n+r-1,r), so CR(5,3)=C(7,3)=35CR(5,3) = C(7,3) = 35.
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 C(n,r)C(n,r) assumes each item can only be chosen once, so rr can never exceed nn. Combinations with replacement drop that restriction: any type can repeat, so rr is free to be larger than nn — 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 CR(n,r)=C(n+r1,r)CR(n,r) = C(n+r-1,r).
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. C(n+r1,r)C(n+r-1,r).
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 CR(n,r)CR(n,r).
What is CR(n,0)?
Choosing 0 items has exactly one outcome — the empty selection — so CR(n,0)=1CR(n,0) = 1 for any nn. This matches the formula: C(n+01,0)=C(n1,0)=1C(n+0-1,0) = C(n-1,0) = 1.

Related calculators