Combination Calculator (nCr and nPr)
Enter the total number of items (n) and how many you are choosing (r) to find how many combinations and permutations are possible. Toggle repetition to cover all four classical selection modes: combinations without repetition, combinations with repetition, permutations without repetition, and permutations with repetition.
Formula
Worked example
For n = 6, r = 2: nPr = 6 x 5 = 30 ordered pairs; nCr = 30 / 2! = 15 unordered pairs. With repetition: C'(6,2) = C(7,2) = 21 pairs; P'(6,2) = 6^2 = 36 ordered pairs.
Combinations vs permutations: which one do you need?
The difference comes down to one question: does order matter? A combination counts how many distinct groups you can form when the arrangement inside the group is irrelevant. Picking 2 fruits from {apple, banana, cherry} gives 3 combinations, because apple-banana is the same group as banana-apple. A permutation counts arrangements, so the same pick yields 6 permutations because apple-then-banana differs from banana-then-apple. Reach for combinations on lottery tickets, poker hands, and committee selections; reach for permutations on race finishes, passwords, and seating charts where the sequence carries meaning.
How the without-repetition formulas work
Permutations without repetition use nPr = n! / (n - r)!. The factorial n! counts every full arrangement of all n items, and dividing by (n - r)! cancels the orderings of the items you did not pick, leaving the falling product n x (n - 1) x ... down to (n - r + 1). Combinations add one more division: nCr = n! / (r! (n - r)!), which is just nPr divided by r!. That extra r! collapses every set of identical members into a single group, since r chosen items can themselves be arranged in r! orders. This calculator builds the result as a running product and divides as it goes, so it never forms an enormous intermediate factorial and stays exact for larger inputs than a naive n! approach.
With-repetition modes: multisets and repeated draws
When items can be reused, the formulas change. Combinations with repetition -- also called a multiset coefficient -- use C'(n, r) = C(r + n - 1, r) = (r + n - 1)! / (r! (n - 1)!). This counts how many multisets of size r you can form from n distinct types when each type can appear any number of times. Classic example: choosing 3 scoops of ice cream from 5 flavors, where you can pick the same flavor twice. Permutations with repetition simplify to P'(n, r) = n^r, because each of the r positions can independently hold any of the n items. This is exactly how PINs and passwords work: a 4-digit PIN from digits 0-9 has 10^4 = 10,000 possible codes.
Probability of a specific combination
In a fair random draw without replacement, every combination of r items from n is equally likely. The probability that a randomly drawn group matches one specific target combination is exactly 1 / C(n, r). This is the foundation of lottery odds: a 6-from-49 lottery has C(49, 6) = 13,983,816 equally likely tickets, so the chance of a single ticket winning the jackpot is about 1 in 14 million. Toggle "Show probability" to see this figure alongside the combination count for any n and r you enter.
Choosing the right selection mode
Use combinations without repetition (the default) whenever you are selecting a group from a pool where each item can be picked at most once and the order of the group does not matter: poker hands, committee rosters, lottery draws, or any subset of a fixed list. Use permutations without repetition when order matters and no item repeats: race podiums, arrangement of distinct objects, anagram counting. Switch to combinations with repetition when items can be reused and the collection itself (not its order) is what counts: ice cream scoops with repeated flavors, distributing identical items across categories. Use permutations with repetition when order matters and repetition is allowed: PINs, lock codes, passwords from a fixed character set.
All four selection modes at a glance
| Mode | Order matters? | Repetition? | Formula | Example |
|---|---|---|---|---|
| Combination (nCr) | No | No | n! / (r!(n-r)!) | Lottery ticket, poker hand |
| Combination with rep C'(n,r) | No | Yes | (r+n-1)! / (r!(n-1)!) | Ice cream scoops (same flavor OK) |
| Permutation (nPr) | Yes | No | n! / (n-r)! | Race podium, seating chart |
| Permutation with rep P'(n,r) | Yes | Yes | n^r | 4-digit PIN, password |
Choose the row that matches your scenario, then use the corresponding mode in this calculator.
Frequently asked questions
What is the difference between a combination and a permutation?
A combination counts selections where order does not matter, while a permutation counts arrangements where order does matter. For the same n and r, the number of permutations equals the number of combinations multiplied by r!, so permutations are always at least as large as combinations.
What happens when r equals n, or r is zero?
When r equals n there is exactly 1 combination (you take the whole set) and n! permutations (every possible ordering). When r is 0, both nCr and nPr equal 1, because there is exactly one way to choose nothing -- the empty selection.
Does this calculator support repetition?
Yes. Switch the "Selection mode" input to "Combinations with repetition" to compute C'(n,r) = C(r+n-1, r), or to "Permutations with repetition" to compute P'(n,r) = n^r. The default mode uses the standard without-repetition formulas, where each item can be chosen at most once.
What does the probability output represent?
When you toggle "Show probability", the calculator displays 1 / nCr -- the probability that a single randomly chosen group of r items from n matches one specific target combination (assuming a fair draw without replacement). This is the direct basis of lottery odds.
Why does the with-repetition formula for combinations use r + n - 1?
Combinations with repetition count multisets of size r drawn from n distinct types. By a classic "stars and bars" argument, this is equivalent to placing r identical balls into n distinct bins, which in turn equals the number of ways to arrange r stars and (n - 1) dividers -- giving C(r + n - 1, r). The formula is just a standard binomial coefficient with shifted arguments, so no new arithmetic is needed beyond what the regular combination formula already computes.
What is the maximum n and r this calculator handles?
The without-repetition formulas stay exact in JavaScript double precision up to roughly n = 60 for nCr and somewhat higher for nPr, after which rounding error accumulates. The permutations-with-repetition formula n^r can overflow to Infinity for large values. The without-repetition inputs are capped at n = 170, which is where 170! reaches the limit of double precision.