Combination with Repetition Calculator
Count ways to choose k items from n types when each type can be chosen more than once.
What it does
A combination with repetition counts how many ways you can choose k items from n types when each type may be chosen repeatedly. Order does not matter, only how many of each type you take.
This tool applies the stars and bars formula C(n plus k minus 1, k). The page opens with five donut varieties and a order of eight donuts, giving 495 possible orders.
The name comes from representing the choice as a row of k stars separated by n minus one bars. Choosing where the stars go among the total positions determines how many items of each type are taken.
The same formula counts the nonnegative integer solutions of x1 plus x2 and so on up to xn equals k, and the number of ways to place k identical objects into n labelled boxes.
Without repetition the answer would be C(n, k), which is smaller. The repetition version is sometimes called a multiset coefficient.
How to use
- Enter the number of distinct types available.
- Enter how many items are chosen.
- Read the number of combinations as the main result.
- Check the binomial form to see the formula applied.
- Try n = 3 and k = 2 to see six possibilities.
- Set k to zero to confirm there is exactly one empty choice.
Formula
- n
- Number of distinct types available.
- k
- Number of items chosen, with repetition allowed.
- C
- The ordinary binomial coefficient.
Represent the choice as k stars and n minus one bars, for a total of n plus k minus one positions. Choosing which k positions hold stars uniquely determines the counts of each type. This establishes the bijection behind the formula.
Worked example
Example: eight donuts from five varieties
The page opens with n = 5 types and k = 8 chosen items.
- Add n plus k minus 1, which is 5 plus 8 minus 1, giving 12.
- Choose k positions, so the expression is C(12, 8), equivalently C(12, 4).
- Evaluate C(12, 4) as 12 times 11 times 10 times 9 divided by 24.
- That product is 11,880 divided by 24, which is 495.
- The tool reports combinations 495 and formula C(12, 4).
- Each of the 495 outcomes is a different multiset of eight donuts.
Reference table
| Types n | Chosen k | Binomial form | Combinations |
|---|---|---|---|
| 5 | 8 | C(12, 4) | 495 |
| 3 | 2 | C(4, 2) | 6 |
Limits
- Types must be whole numbers from 1 to 100.
- Chosen items must be whole numbers from 0 to 100.
- The sum of types and chosen items is limited to 200.
- Items of the same type are treated as identical.
Common mistakes
- Using C(n, k), which forbids repetition.
- Adding one instead of subtracting one in n plus k minus 1.
- Confusing types with the number of items chosen.
- Counting order as significant when it should not be.
- Forgetting that k = 0 gives one valid empty selection.
Try it yourself
Quick checks. Answers sit tucked under each question.
Three types, choose two with repetition. How many?
6, from C(4, 2).
Five varieties, eight donuts. How many orders?
495, from C(12, 4).
What equation has the same count?
The nonnegative integer solutions of x1 plus x2 up to xn equal k.
Questions
What does repetition mean here?
The same type may be chosen more than once.
What is the formula?
C(n plus k minus 1, k).
Why stars and bars?
Stars represent chosen items and bars separate the types, giving a bijection with the selections.
Does order matter?
No. Only the count of each type matters.
How is this different from permutations with repetition?
Permutations count order, while combinations do not.
What if each type can be chosen at most once?
Then the answer is the ordinary combination C(n, k).
Sources
- University of Toronto MAT344 lecture 3 on stars and bars
- MIT 6.042 lecture notes on combinations with repetition
- Whitman College, choice with repetition