How to use the permutation and combination calculator
- Enter n, the number of different items you are choosing from.
- Enter r, how many of them you choose.
- Tick Repetition allowed if the same item can be picked more than once (like the digits of a PIN).
The calculator shows both answers — permutations and combinations — with the factorial working. Answers are exact, even when they have thousands of digits; very long results are also shown in scientific notation. When the count is small, every arrangement is listed using the letters A, B, C… so you can see where the number comes from.
Does order matter?
That one question decides which formula you need.
- Permutation — order matters. Gold, silver and bronze for Ana, Ben and Cy is a different result from gold for Cy, silver for Ben and bronze for Ana. Codes, passwords, rankings, schedules and seating plans are permutations.
- Combination — order doesn’t matter. A pizza with ham and mushroom is the same pizza as one with mushroom and ham. Teams, committees, card hands and lottery tickets are combinations.
(Funnily enough, a “combination lock” is really a permutation lock — 1-2-3 will not open a lock set to 3-2-1.)
The formulas
The exclamation mark means factorial: n! = n × (n − 1) × … × 2 × 1, and 0! = 1.
| No repetition | Repetition allowed | |
|---|---|---|
| Order matters (permutation) | nPr = n! ÷ (n − r)! | nr |
| Order doesn’t matter (combination) | nCr = n! ÷ (r! × (n − r)!) | C(n + r − 1, r) |
You will also see nPr written as P(n, r) and nCr written as C(n, r), “n choose r”, or as a tall bracket with n above r.
Why the factorials cancel
You never need to multiply out the whole of n!. In 10! ÷ 7!, the factors 7 × 6 × … × 1 appear on both top and bottom, so they cancel and only 10 × 9 × 8 is left. That is just the counting principle: 10 choices for the first place, 9 for the second, 8 for the third.
Worked example
Ten runners race. How many ways can gold, silver and bronze be awarded? Order matters, so this is a permutation:
10P3 = 10! ÷ 7! = 10 × 9 × 8 = 720.
How many ways can 3 of the 10 runners be picked for a relay team? Order doesn’t matter, so this is a combination:
10C3 = 10! ÷ (3! × 7!) = (10 × 9 × 8) ÷ (3 × 2 × 1) = 720 ÷ 6 = 120.
The two answers are linked. Each team of 3 can be lined up in 3! = 6 different orders, so there are 6 times as many permutations as combinations: nPr = nCr × r!
When repetition is allowed
Ordered with repetition: each of the r positions can be any of the n items, so there are n × n × … × n = nr possibilities. A 4-digit PIN has 10⁴ = 10,000 possibilities. (More on powers in the exponent calculator.)
Unordered with repetition: choosing 3 scoops of ice cream from 5 flavours, where you may repeat a flavour, gives C(5 + 3 − 1, 3) = C(7, 3) = 35 possible bowls. This is sometimes called the “stars and bars” formula.
Using counts to find probabilities
Counting is the first step of many probability problems: probability = favourable outcomes ÷ total outcomes. There are 52C5 = 2,598,960 possible five-card hands, and only 4 of them are royal flushes, so the chance of being dealt one is 4 ÷ 2,598,960 — about 1 in 650,000. You can test simpler probabilities by experiment with the probability simulator.
Frequently asked questions
What is the difference between a permutation and a combination?
In a permutation the order of the chosen items matters, so AB and BA are counted separately. In a combination order does not matter, so AB and BA are the same selection. There are r! times as many permutations as combinations.
What is the formula for nPr and nCr?
nPr = n! ÷ (n − r)! and nCr = n! ÷ (r! × (n − r)!). For example 5P2 = 5 × 4 = 20 and 5C2 = 20 ÷ 2 = 10.
How do I know whether to use a permutation or a combination?
Ask whether rearranging the same items gives a different result. If it does, as with rankings, codes and seating, use a permutation. If it does not, as with teams, hands of cards and toppings, use a combination.
What is 0 factorial, and what are nP0 and nC0?
0! is defined as 1. Both nP0 and nC0 equal 1, because there is exactly one way to choose nothing.
How do I calculate permutations with repetition?
If each of r positions can be filled by any of n items, there are n to the power r arrangements. A 3-letter code using 26 letters has 26 × 26 × 26 = 17,576 possibilities.
How large can n and r be in this calculator?
Up to 1,000 each. The calculator uses exact big-integer arithmetic, so even answers with thousands of digits are shown in full, along with a scientific-notation approximation.