Combinations with Repetition Calculator
Count unordered selections when the same object may be chosen more than once, and generate the full list for compact cases.
Inputs
Required integer from 1 to 10,000. Commas are accepted only as thousands separators.
Required integer from 0 to 10,000. A sample size of 0 has exactly one empty combination.
Live result
Combinations with repetitions
20
C′(n,r) = (n + r – 1)! / (r!(n – 1)!)
For n = 4 and r = 3: C(6,3) = 20.
There are 20 unordered selections of 3 objects from 4 object types when repetition is allowed.
Combination generator
Showing all 20 combinations using A – D.
| # | Combination |
|---|---|
| 1 | A · A · A |
| 2 | A · A · B |
| 3 | A · A · C |
| 4 | A · A · D |
| 5 | A · B · B |
| 6 | A · B · C |
| 7 | A · B · D |
| 8 | A · C · C |
| 9 | A · C · D |
| 10 | A · D · D |
| 11 | B · B · B |
| 12 | B · B · C |
| 13 | B · B · D |
| 14 | B · C · C |
| 15 | B · C · D |
| 16 | B · D · D |
| 17 | C · C · C |
| 18 | C · C · D |
| 19 | C · D · D |
| 20 | D · D · D |
How to use this combinations with repetition calculator
What this calculator does
This calculator finds the number of unordered samples of size r that can be formed from n distinct object types when an object type may be used repeatedly. In combinatorics, the result is a multiset count, sometimes called “n multichoose r.” Order is deliberately ignored: A · B · B and B · A · B represent the same combination. The calculator does not count ordered strings or permutations, and it does not assign probabilities unless every combination is known to be equally likely under a separate random process. For the underlying stars-and-bars argument, the MIT Mathematics for Computer Science lecture on combinations with repetition gives a formal derivation.
When to use it
Use the calculator when you are choosing a fixed number of items from categories and repeats are allowed: selecting three scoops from four ice-cream flavors when flavor order is irrelevant, assembling a dozen doughnuts from several available types, counting nonnegative integer allocations across categories, or checking a stars-and-bars exercise. If the order of the selections matters, use a permutation model instead. If repeats are forbidden, use an ordinary combination model.
How to calculate
- The calculator opens with a ready-to-use demonstration: n = 4 and r = 3. Its exact result, 20, is already calculated, the compact combination list is populated, and the example XLSX export is immediately available.
- Replace Total number of objects n with the number of distinct object types. Then replace Sample size r with the number of objects selected in each combination. Results update live without a Calculate button.
- Read Combinations with repetitions for the exact unordered count. For compact cases, also inspect the Combination generator, whose rows show each unique multiset once.
- Choose Download Excel to export the current validated inputs, result, formula notes, and generated combinations when available. Reset clears the demonstration values and results rather than restoring them; after Reset, Excel export remains disabled until both required fields form a complete valid state again.
Input guide
Total number of objects n is required and means the number of distinct types available before selection. Enter a whole number from 1 through 10,000; plain digits such as 4 or correctly grouped thousands such as 1,000 are accepted. Increasing n generally increases the count because more distinct types can appear in the multiset. Do not enter a decimal, scientific notation such as 1e3, a negative number, or an ambiguous grouping such as 1,5. A realistic example is n = 4 for four flavors.
Sample size r is required and means how many objects the unordered sample contains. Enter a whole number from 0 through 10,000. The value r = 0 is mathematically valid and produces one empty combination; positive r values describe nonempty samples. Raising r generally increases the number of repeated-selection patterns when n is greater than 1. A realistic example is r = 3 for a three-item selection. Do not confuse sample size with the number of distinct types that must appear; repetition means some types may appear several times while others may not appear at all.
Output guide
Combinations with repetitions is the exact integer number of unordered multisets. It is driven by both n and r and is an identity, not a statistical estimate. A value of 1 occurs in boundary cases such as r = 0 or n = 1. Large values are displayed as exact integers rather than scientific notation. The Combination generator provides a concrete list only when n ≤ 5 and r ≤ 10, matching a practical upper bound for readable enumeration. Its first column is the row number; its Combination column uses symbols A through E and lists each selection in nondecreasing order so equivalent reorderings are not repeated. The generator status text tells you whether the complete list is shown or intentionally omitted while the exact count remains available.
Worked example
With the startup values n = 4 and r = 3, transform the problem into an ordinary binomial coefficient: n + r – 1 = 6, so the count is C(6,3). Evaluating 6!/(3!3!) gives 20. The generator therefore lists exactly 20 rows, beginning with A · A · A and ending with D · D · D. This agrees with the multichoose interpretation described by Wolfram MathWorld's multichoose reference, where repeated selections are treated as multisets.
Why the formula works
The standard formula is based on converting a multiset choice into a stars-and-bars arrangement. Imagine r stars representing the selected objects and n – 1 separators dividing those stars among n object types. There are n + r – 1 positions in total, and choosing where the r stars go uniquely determines how many copies of each type are selected. Therefore the count is the binomial coefficient C(n + r – 1, r), which is algebraically the same as (n + r – 1)! divided by r!(n – 1)!.
The calculator evaluates this coefficient with exact integer arithmetic using a multiplicative form rather than computing enormous factorials directly. That preserves exact results across the supported input range. The NIST Digital Library of Mathematical Functions section on binomial coefficients documents the ordinary coefficient that appears after the stars-and-bars transformation.
Combinations with repetition versus permutations
The essential question is whether rearranging the same selected objects creates a new outcome. For this calculator, it does not. With object types A and B and sample size 3, AAB, ABA, and BAA all collapse to the same multiset A · A · B. If order mattered, those would be separate sequences and the counting rule would be different. Repetition is a second, independent issue: this calculator allows A · A · B, whereas a combination without repetition would forbid selecting A twice.
This distinction matters in practical modeling. A box containing two chocolate doughnuts and one glazed doughnut is the same assortment regardless of the order in which the doughnuts were placed into the box. By contrast, a three-character code treats ABC and BAC as different because position has meaning. The ordinary combination definition summarized by MathWorld's combination reference is useful for comparing the no-repetition case with the repeated-selection model used here.
Common mistakes and edge cases
- Using nr: that expression counts ordered length-r sequences with repetition, not unordered combinations.
- Using C(n,r): ordinary combinations prohibit repetition and require a different interpretation.
- Assuming r must be no larger than n: with repetition, r can exceed n because the same type can appear multiple times.
- Expecting the generator for huge cases: enumeration becomes unreadable quickly. The exact count still works beyond the generator's compact n ≤ 5 and r ≤ 10 range.
- Reading a lock code as a combination: everyday language often calls ordered codes “combinations,” but mathematically their positions usually make them permutations or sequences.
Boundary behavior is useful for checking your reasoning. If r = 0, there is exactly one empty multiset. If n = 1, there is exactly one possible multiset for any supported r because every selected object must be the sole available type. These identities are handled directly by the same formula.