Combinations Replacement Calculator

Combinations Replacement Calculator

Popular AI Skill PRO

Enter Calculation

Formula

CR(n,r)=(n+r−1)!r!(n−1)!C^{R}(n,r) = \frac{(\text{n} + \text{r} - 1)!}{\text{r}!\,(\text{n} - 1)!}
Usage stats

Advertisement

Results

Number of combinations with replacement
35
Total number of types of items (n) 5
Number of items to choose (r) 3

Report an error on this page

What This Calculator Does

The Combinations with Replacement Calculator counts how many ways you can choose r items from n distinct types when repetition is allowed and the order of selection does not matter. This is a core formula in combinatorics and probability, often called the "stars and bars" problem. Because each type can be picked more than once, the count is larger than ordinary combinations without replacement.

Selecting items from three types with repetition allowed, forming a multiset
Combinations with replacement let the same item type be chosen more than once.

The Inputs You Enter

  • Total number of types of items (n): how many distinct categories you can choose from — for example 3 flavours of ice cream.
  • Number of items to choose (r): how many picks you make in total, where the same type may be selected repeatedly.

Enter both as whole numbers and the calculator instantly returns a single result: the number of distinct multisets (unordered selections allowing repeats).

The Formula

The tool applies the standard combinations-with-replacement equation:

$$C^{R}(n,r) = \frac{(n + r - 1)!}{r!\,(n - 1)!}$$

Internally it computes three factorials — \((n + r - 1)!\), \(r!\) and \((n - 1)!\) — then divides as shown. Because it uses exact factorials with whole-number arithmetic, the result is an exact integer count, not an approximation.

Advertisement
Stars and bars arrangement representing combinations with replacement
The stars-and-bars method explains why the count equals \(C(n+r-1, r)\).

Worked Example

Suppose an ice cream shop offers n = 3 flavours and you want a cup with r = 2 scoops, where you may repeat a flavour. Plug in n = 3 and r = 2:

  • \(n + r - 1 = 3 + 2 - 1 = 4\)
  • $$C(4, 2) = \frac{4!}{2! \cdot 2!} = \frac{24}{2 \cdot 2} = \mathbf{6}$$

So there are 6 possible two-scoop cups: AA, BB, CC, AB, AC and BC. The calculator returns 6 instantly.

More Worked Examples

Each example below uses the same identity, \(C^{R}(n,r) = \binom{n+r-1}{r} = \frac{(n+r-1)!}{r!\,(n-1)!}\), where \(n\) is the number of distinct item types available and \(r\) is how many items are chosen. Order does not matter and every type may be reused, so each outcome is a multiset.

Example 1 — Three identical dice (n = 6, r = 3)

You roll three indistinguishable six-sided dice and record only the set of faces showing (so 1-3-6 and 6-3-1 count as the same outcome). There are \(n = 6\) face types and \(r = 3\) picks, with repetition allowed because two dice can show the same face.

Top index: \(n + r - 1 = 6 + 3 - 1 = 8\).

$$C^{R}(6,3) = \binom{8}{3} = \frac{8!}{3!\,5!} = \frac{8 \times 7 \times 6}{3 \times 2 \times 1} = \frac{336}{6} = 56$$

So there are 56 distinct unordered face combinations. Note that this is far fewer than the \(6^3 = 216\) ordered rolls — the 216 ordered outcomes collapse onto the 56 multisets, but unevenly (a triple like 4-4-4 has one ordering, while 1-3-6 has six), which is exactly why dice-sum probabilities must be computed from the 216 ordered rolls and not from the 56 multisets.

Example 2 — More scoops than flavours (n = 3, r = 5)

An ice-cream shop offers 3 flavours and you order a 5-scoop tub; scoops of the same flavour are allowed and the order they are packed in does not matter. Here \(r = 5\) is larger than \(n = 3\), which is impossible for combinations without replacement but perfectly fine here.

Top index: \(n + r - 1 = 3 + 5 - 1 = 7\).

$$C^{R}(3,5) = \binom{7}{5} = \frac{7!}{5!\,2!} = \frac{7 \times 6}{2 \times 1} = \frac{42}{2} = 21$$

There are 21 possible tubs. Cancelling \(5!\) instead of \(2!\) is the shortcut here: because \(\binom{7}{5} = \binom{7}{2}\), only two numerator factors survive. In stars-and-bars terms, you are placing 5 stars (scoops) and \(n - 1 = 2\) bars (flavour dividers) in 7 slots — for instance \(\star\star\,|\,\star\,|\,\star\star\) means 2 vanilla, 1 chocolate, 2 strawberry.

Example 3 — The two edge cases (r = 1 and n = 1)

Choosing one item (n = 4, r = 1). You pick a single drink from 4 sizes. With only one pick, repetition can never occur, so the answer must simply be the number of types:

$$C^{R}(4,1) = \binom{4+1-1}{1} = \binom{4}{1} = \frac{4!}{1!\,3!} = \frac{4}{1} = 4$$

which gives 4 outcomes — the \(r = 1\) column of any such table is always just \(n\).

Only one type (n = 1, r = 7). A vending machine stocks a single product and you buy 7 units:

$$C^{R}(1,7) = \binom{1+7-1}{7} = \binom{7}{7} = \frac{7!}{7!\,0!} = \frac{5040}{5040 \times 1} = 1$$

There is exactly one multiset — "seven of the only thing available" — because with one type there are no choices left to make. Formally \(n - 1 = 0\) bars are needed, all 7 positions must be stars, and \(\binom{7}{7} = 1\). The same logic makes \(C^{R}(n,0) = 1\) for any \(n\): choosing nothing is one valid (empty) selection, which is why \(0! = 1\) is the convention that keeps the formula consistent.

Combinations with Replacement Reference Table

Exact values of \(C^{R}(n,r) = \binom{n+r-1}{r}\) for 1–8 item types chosen 1–6 at a time. Read down to your number of types \(n\), then across to the number of picks \(r\).

Number of unordered selections with repetition allowed
n (types) r = 1 r = 2 r = 3 r = 4 r = 5 r = 6
1 1 1 1 1 1 1
2 2 3 4 5 6 7
3 3 6 10 15 21 28
4 4 10 20 35 56 84
5 5 15 35 70 126 210
6 6 21 56 126 252 462
7 7 28 84 210 462 924
8 8 36 120 330 792 1716

How to read the patterns

  • Every row is a diagonal of Pascal's triangle. Row \(n = 1\) is the constant sequence of 1s, row \(n = 2\) is the natural numbers \(2, 3, 4, \dots\), row \(n = 3\) is the triangular numbers \(3, 6, 10, 15, 21, 28\), and row \(n = 4\) is the tetrahedral numbers \(4, 10, 20, 35, 56, 84\). This is simply \(\binom{n+r-1}{r}\) traced along fixed \(n\).
  • The table is symmetric under a shift. Because \(\binom{n+r-1}{r} = \binom{n+r-1}{n-1}\), we get \(C^{R}(n,r) = C^{R}(r+1,\,n-1)\). For example \(C^{R}(6,3) = 56 = C^{R}(4,5)\), and \(C^{R}(8,3) = 120 = C^{R}(4,7)\). Swapping the roles of "types" and "picks" this way often turns a long multiplication into a short one.
  • Growth is polynomial in r, of degree n − 1. Holding \(n\) fixed, \(C^{R}(n,r) = \frac{(r+1)(r+2)\cdots(r+n-1)}{(n-1)!}\), a polynomial of degree \(n-1\) — linear for \(n = 2\), quadratic for \(n = 3\), cubic for \(n = 4\). Holding \(r\) fixed and growing \(n\) behaves the same way with the roles reversed (degree \(r\) in \(n\)). Either way the counts stay far below the \(n^{r}\) count of ordered selections with repetition.
  • Each entry is the sum of the one above it and the one to its left (where both exist): \(C^{R}(n,r) = C^{R}(n-1,r) + C^{R}(n,r-1)\). Check \(126 = 70 + 56\) in the \(n = 6\), \(r = 4\) cell. That recurrence is a quick way to extend the table by hand.
Advertisement

How to Calculate It by Hand

The stars-and-bars picture

Before the arithmetic, it helps to see why the formula has that shape. Represent a selection as \(r\) identical stars (the items you take) separated into \(n\) groups by \(n-1\) bars (the dividers between consecutive item types). The number of stars in group \(i\) is how many copies of type \(i\) you chose. Every arrangement of \(r\) stars and \(n-1\) bars corresponds to exactly one valid selection, and there are \(r + (n-1) = n + r - 1\) positions in the row. Counting the selections therefore means choosing which \(r\) of those \(n+r-1\) positions hold stars:

$$C^{R}(n,r) = \binom{n+r-1}{r} = \binom{n+r-1}{n-1}$$

For example with \(n = 4\) types and \(r = 5\) picks, the row \(\star\,|\,|\,\star\star\star\,|\,\star\) has 8 positions and means 1 of type A, none of type B, 3 of type C, 1 of type D.

Step-by-step procedure

  1. Check the inputs. Confirm that \(n\) and \(r\) are whole numbers with \(n \ge 1\) and \(r \ge 0\). Unlike combinations without replacement, \(r\) may exceed \(n\) — repetition is allowed, so there is no upper bound on \(r\).
  2. Compute the top index. Work out \(N = n + r - 1\). This is the total number of star-and-bar positions.
  3. Write the binomial. \(C^{R}(n,r) = \dbinom{N}{r} = \dfrac{N!}{r!\,(n-1)!}\). Never expand these factorials in full — \(N!\) explodes quickly and the big numbers all cancel.
  4. Cancel \((n-1)!\) against \(N!\). Since \(N - r = n - 1\), the quotient \(N!/(n-1)!\) leaves exactly \(r\) descending factors in the numerator:
$$C^{R}(n,r) = \frac{(n+r-1)(n+r-2)\cdots(n)}{r!}$$
  1. Multiply the \(r\) numerator terms, then divide by \(r!\). If \(r\) is larger than \(n-1\), use the symmetry \(\binom{N}{r} = \binom{N}{n-1}\) first so you multiply the smaller number of factors instead.
  2. Sanity-check that the result is a whole number. A binomial coefficient is always an integer, so any leftover fraction or remainder means an arithmetic slip. Two more quick checks: \(r = 1\) must give exactly \(n\), and \(n = 1\) must give exactly 1.

Worked run-through (n = 5, r = 4)

Four scoops of frozen yoghurt from 5 toppings, repeats allowed, order irrelevant.

  • Step 2: \(N = 5 + 4 - 1 = 8\).
  • Step 3: \(C^{R}(5,4) = \dfrac{8!}{4!\,4!}\).
  • Step 4: cancel \((n-1)! = 4!\), leaving \(r = 4\) descending factors from 8 down to \(n = 5\): \(\dfrac{8 \times 7 \times 6 \times 5}{4!}\).
  • Step 5: \(\dfrac{1680}{24} = 70\).
  • Step 6: 70 is a whole number, and it matches the \(n = 5\), \(r = 4\) cell of the reference table above.

The answer is 70 distinct topping combinations. A useful contrast: the same inputs give \(5^4 = 625\) if order matters, and only \(\binom{5}{4} = 5\) if repetition is forbidden — so always decide whether order and repetition apply before picking a formula.

Frequently Asked Questions

How is this different from regular combinations? Ordinary combinations, \(C(n, r)\), forbid repeats — each item is chosen at most once. Combinations with replacement allow the same type to be picked multiple times, which is why we shift to \(C(n + r - 1, r)\).

Does order matter here? No. AB and BA count as the same selection. If order mattered you would use permutations instead.

Can r be larger than n? Yes. Since repetition is allowed, you can choose more items than there are types — for instance picking 5 scoops from 3 flavours is perfectly valid and gives a larger count.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators