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
- Enter Types to choose from (n) — for example, 5 kinds of donut.
- Enter Items chosen (r) — for example, 12 donuts. Here r may be larger than n.
- Read the number of different selections on the tape, with the comparison counts for “no repeats” and “order matters too”.
- 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
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.