Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Number of combinations with repetition (nHr)
10
multisets of size r from n types
Distinct types (n) 4
Items chosen (r) 2
Formula C(n + r − 1, r)

What is combinations with repetition?

Combinations with repetition count the number of ways to choose r items from n distinct types when you are allowed to pick the same type more than once and the order of selection does not matter. This quantity is often written as nHr and is also called the multiset coefficient. It answers questions like "how many different scoops can I get from 4 ice-cream flavors if I take 2 scoops and repeats are fine?"

Selecting scoops from three flavor bins allowing repeats, with two example multiset selections
Combinations with repetition: choosing items from distinct types where the same type can be picked more than once and order does not matter.

How to use this calculator

Enter the number of distinct types n (must be at least 1) and the number of items you wish to choose r (zero or more). Click calculate and the tool returns nHr, the exact number of distinct multisets. Both inputs are plain non-negative integers; there are no units to convert.

The formula explained

The core identity is $$\overline{C}(n,r) = \binom{n + r - 1}{r} = \frac{(n + r - 1)!}{r! \cdot (n - 1)!}.$$ The trick: lining up \(r\) chosen items and \((n - 1)\) dividers between the types gives \(n + r - 1\) positions, and we choose where the items (or dividers) go. To avoid huge factorials, this calculator evaluates the binomial coefficient with a stable multiplicative loop, multiplying by \((m - k + i)\) and dividing by \(i\) for \(i = 1..k\), where \(m = n + r - 1\) and \(k = \min(r, n - 1)\).

Advertisement
Stars and bars diagram showing r stars distributed among n bins using n minus 1 bars
The stars and bars model: r identical items (stars) separated into n types by n-1 dividers (bars), giving C(n+r-1, r) arrangements.

Worked example

With the defaults \(n = 4\), \(r = 2\): $$\overline{C}(n,r) = \binom{4 + 2 - 1}{2} = \binom{5}{2} = \frac{5 \cdot 4}{2 \cdot 1} = 10.$$ The ten combinations from types {a, b, c, d} are: aa, ab, ac, ad, bb, bc, bd, cc, cd, dd.

FAQ

How is this different from ordinary combinations? Ordinary combinations \(C(n, r)\) forbid repetition, so each item is chosen at most once; here repetition is allowed, giving a larger count.

What if r = 0? There is exactly one combination: the empty selection, so \(\overline{C}(n,r) = 1\).

What if n = 1? With only one type you must pick it \(r\) times, so there is exactly one multiset and \(\overline{C}(n,r) = 1\) for any \(r\).

Last updated: