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.
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.
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.
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.