Combinations with Replacement Calculator

Count unordered selections in which the same type can be picked again — scoops, donuts, dice faces — using the stars-and-bars formula.

How many different kinds of item are available, e.g. 10 flavors.
How many you pick. Types may repeat and order does not matter; r may exceed n.
Same as C(n + r − 1, r)
C(12, 3)stars and bars: 3 stars, 9 bars
No repeats, C(n, r)
120each type used at most once
Order matters too, nʳ
1,00010³ ordered sequences
Combinations with repetition2203 digits

Show the work

  1. Picture each selection as a row of 3 stars (the items) split into 10 groups by 9 bars (one group per type). Every way to place the bars gives a different selection.
  2. For example, the selection AAC is the row ★★ | | ★ | | | | | | | — 3 stars and 9 bars in 12 slots.
  3. So we choose which 3 of the 12 slots hold stars: CR(n, r) = C(n + r − 1, r) = (n + r − 1)!r! · (n − 1)!
  4. Substitute n = 10 and r = 3: C(12, 3) = 12!3! · 9!
  5. Cancel 9! against the top, leaving 12 × 11 × 103 × 2 × 1
  6. Multiply out and divide: 1,3206 = 220

Sometimes you choose from a set of types, any type can be chosen again, and the order of the picks does not matter. A box of a dozen donuts from five kinds, three scoops from ten flavors, or the coins in your pocket are all selections of this kind. Mathematicians call them combinations with repetition, multisets or “n multichoose r”. This calculator counts them exactly, explains the count with stars and bars, and can list every selection when the numbers are small.

How to use the combinations with replacement calculator

  1. Enter Types to choose from (n) — for example, 5 kinds of donut.
  2. Enter Items chosen (r) — for example, 12 donuts. Here r may be larger than n.
  3. Read the number of different selections on the tape, with the comparison counts for “no repeats” and “order matters too”.
  4. Tick List the combinations to see every selection written with letters, such as AAB or BCC (up to 26 types and 12 items).

Combinations with replacement formula

CR(n, r) = C(n + r − 1, r) = (n + r − 1)! ÷ (r! · (n − 1)!)

The formula turns a problem with repetition into an ordinary combinations problem on a larger set, which is why the answer is always a binomial coefficient and appears in Pascal’s triangle.

Why stars and bars works

Draw each selection as a row of symbols: one star ★ for every item and a bar | between consecutive types. With 10 flavors and 3 scoops, two scoops of flavor A and one of flavor C is

★ ★ | | ★ | | | | | | |

The 9 bars split the row into 10 compartments; the number of stars in a compartment is how many scoops of that flavor you took. Every selection gives one row and every row gives one selection, so you only need to count rows. A row has 3 + 9 = 12 slots, and you choose which 3 hold stars: C(12, 3) = 220 different cups.

Worked example: a dozen donuts from five kinds

A shop sells 5 kinds of donut and you want a box of 12, any mix allowed. Here n = 5 and r = 12, so the stars-and-bars row has 12 stars and 4 bars in 16 slots.

C(5 + 12 − 1, 12) = C(16, 12) = 16! ÷ (12! · 4!)

Cancel 12!: (16 × 15 × 14 × 13) ÷ (4 × 3 × 2 × 1)

= 43,680 ÷ 24 = 1,820 different boxes

Comparing the four ways to count

For 3 picks from 10 types, the four classic counting rules give very different answers:

Order matters? Repeats allowed? Formula Count
No No C(10, 3) 120
No Yes C(12, 3) 220
Yes No P(10, 3) 720
Yes Yes 10³ 1,000

If the order of picks matters and repeats are allowed — PINs, passwords, license plates — use the permutations with replacement calculator.

The same count in disguise

Combinations with replacement show up under other names:

  • Identical objects in distinct boxes. Handing 10 identical candies to 3 children can be done C(12, 2) = 66 ways, since the candies are the stars and the children are the types.
  • Non-negative integer solutions. The equation x₁ + x₂ + x₃ = 10 with whole numbers x ≥ 0 has the same 66 solutions.
  • Monomials. The number of terms of degree r in n variables, such as x², xy and y² for n = 2 and r = 2, is C(n + r − 1, r).

A caution about probability

The calculator counts distinct selections; it does not claim they are equally likely. Three dice rolled together show C(8, 3) = 56 different unordered results, yet {6, 6, 6} arises from only one of the 216 ordered rolls while {1, 2, 3} arises from six. For probabilities with dice, count ordered outcomes (6³ = 216) or try the dice roller to see the difference in practice.

Frequently asked questions

When should I use combinations with replacement?

Use it when the same kind of item can be chosen more than once and the order of the picks does not matter: a dozen donuts from several kinds, scoops in a cup, or the faces showing on dice rolled together.

Can r be larger than n?

Yes. Because types can repeat, you can pick more items than there are types. Choosing 12 donuts from 5 kinds gives C(16, 12) = 1,820 different boxes.

What is the stars and bars method?

Write each selection as a row of r stars (the items) and n − 1 bars that split the stars into n groups, one per type. Every selection matches exactly one row, so the count is the number of ways to place r stars among n + r − 1 slots, C(n + r − 1, r).

Is this the same as n to the power r?

No. The power nʳ counts ordered sequences in which repeats are allowed, such as PIN codes. Three scoops from 10 flavors give 10³ = 1,000 ordered sequences but only 220 different cups, because order is ignored.

Are all the combinations equally likely when rolling dice?

No. Three dice show 56 different unordered outcomes, but {1, 1, 1} can happen only one way while {1, 2, 3} can happen six ways. The count of outcomes is correct; their probabilities are not equal.

Last reviewed October 2026 by the CalcFluent editorial team. How we check our calculators.