Permutation and Combination Calculator
Calculate permutations (nPr) and combinations (nCr) for probability problems.
Related calculators
About
Permutation and Combination Calculator
Permutations and combinations belong to a branch of mathematics called combinatorics, which studies finite, discrete structures. Permutations are selections of elements from a set where the order they are arranged in matters. Combinations are selections where order is ignored.
A combination lock is the standard example of the name being wrong. It should technically be called a permutation lock, because the order of the numbers entered matters: 1-2-9 is not the same as 2-9-1. For a genuine combination, any order of those three numbers would do.
Several types of each exist. The calculator above covers the case without replacement, also called without repetition, which is the usual meaning. For the lock example that means it does not handle a code with repeated values such as 3-3-3, though the table underneath shows what those cases would give.
Permutations
The calculator computes one of the most typical concepts of permutations, where arrangements of a fixed number of elements r are taken from a given set n. These are known as r-permutations of n, or partial permutations, denoted , or among others.
Without replacement, every possible way that elements in a set can be listed in a particular order is considered, but the number of choices shrinks each time an element is picked. That is the difference from a "combination" lock, where a value can occur multiple times.
Take a football team of 11 players, and the job of picking a captain and a goalkeeper. The two cannot be the same person, so once one is chosen they leave the pool:
A B C D E F G H I J K, 11 members; A is chosen as captain
B C D E F G H I J K, 10 members; B is chosen as keeper
The first choice was A as captain out of 11. Since A cannot also be the goalkeeper, A is removed from the set before B is picked as keeper from the remaining 10.
If every single position in the team had to be filled, the total would be 11 × 10 × 9 × 8 × 7 × … × 2 × 1, or 11 factorial, written 11!. But only the captain and the goalkeeper mattered here, so only the first two choices are relevant: 11 × 10 = 110. The equation therefore removes the rest of the elements, 9 × 8 × 7 × … × 2 × 1, which is 9!.
where:
- n is the total number of items in the set
- r is how many are being chosen and arranged
- ! is the factorial, the product of every whole number from 1 up to that value
Or in this case specifically:
The calculator does not handle permutations with replacement, but for the curious the equation is simply , since every one of the r choices has all n options available.
Combinations
Combinations are permutations with the redundancies removed, because order does not matter. They are denoted , , or most commonly as the binomial coefficient written as n above r in brackets.
Using the football team again, find the number of ways to choose 2 strikers from 11. Unlike the captain and goalkeeper case, where the captain was chosen first and then the keeper, the order the strikers are chosen in does not matter, since they will both be strikers. Picking A then B, and picking B then A, give the same pair.
The number of arrangements of all n people is n!, as in the permutations section. To get combinations, the redundancies have to be removed from the total number of permutations, which was 110. In this case the redundancy is 2!, because two chosen players can be ordered in 2 ways: A then B, or B then A.
Or specifically:
It makes sense that there are fewer combinations than permutations, since the redundancies are being removed. For the curious again, combinations with replacement follow:
The relationship between them
The two formulas differ by exactly one factor:
Every combination of r items can be arranged in r! different orders, and permutations count all of those separately while combinations count them once. That single division is the whole difference.
It also explains why the gap widens fast. Choosing 2 from 6 gives 30 permutations and 15 combinations, a factor of 2. Choosing 5 from 10 gives 30,240 permutations and 252 combinations, a factor of 120, because 5! is 120.
The four cases
Whether order matters and whether items can repeat are independent questions, which gives four formulas rather than two.
| Case | Formula | Example: 2 from 6 |
|---|---|---|
| Order matters, no repeats | 30 | |
| Order matters, repeats allowed | 36 | |
| Order ignored, no repeats | 15 | |
| Order ignored, repeats allowed | 21 |
Deciding which one applies is usually harder than the arithmetic. Two questions settle it: does swapping two picks give a different outcome, and can the same item be picked twice? A four-digit PIN allows repeats and cares about order, so it is 104 = 10,000. A lottery draw of 6 balls from 49 allows neither repeats nor ordering, so it is 49C6 = 13,983,816.
Factorials
The factorial of n is the product of every whole number from 1 to n, so 5! = 5 × 4 × 3 × 2 × 1 = 120. It counts the number of ways n distinct items can be arranged in a row.
By definition 0! = 1, which looks odd until you notice it has to be: there is exactly one way to arrange nothing, and the permutation formula breaks without it. Setting r = n gives nPn = n! / 0!, which should equal n!, and only works if 0! is 1.
Factorials grow faster than almost anything else in elementary mathematics. 10! is 3.6 million, 20! is around 2.4 × 1018, and 70! exceeds the estimated number of atoms in the observable universe. This calculator uses arbitrary-precision integers so results stay exact rather than drifting into floating-point approximation, which ordinary calculators start doing above 21!.
This is also why the formulas are never actually computed as written. Working out 100P2 as 100! divided by 98! would build two enormous numbers to return 9,900. The calculator multiplies only the terms that survive, 100 × 99, which is the same answer for a fraction of the work.
Where these turn up
Probability is the main one. The chance of any specific lottery ticket winning a 6-from-49 draw is 1 in 13,983,816, which is 49C6, and the ordering is ignored because the balls are sorted afterwards.
Card problems run on the same machinery. A five-card poker hand from a 52-card deck is 52C5 = 2,598,960 possible hands, and every probability in the game is some count divided by that number.
Password strength is a permutations-with-replacement problem: a 12-character password drawn from 95 printable ASCII characters has 9512 possibilities, roughly 5.4 × 1023. Adding one character multiplies the space by 95, which is why length beats complexity.
Binomial coefficients, which is what nCr values are, appear as the rows of Pascal's triangle and as the coefficients when expanding (a + b)n. They also sit inside the binomial distribution, which is how you work out the chance of exactly k successes in n trials.
Common mistakes
The first is treating order as mattering when it does not. Committee selections, lottery draws, poker hands and pizza toppings are combinations. Race finishes, PINs, seating arrangements and passwords are permutations. If swapping two of your picks changes the outcome, it is a permutation.
The second is missing repetition. Rolling a die three times allows repeats; dealing three cards does not. The word "combination" in ordinary speech carries no information about either, which is why the lock is misnamed.
The third is r exceeding n. You cannot choose 5 items from a set of 3 without replacement, and the calculator says so rather than returning a meaningless number.
Common questions
Frequently asked questions
Order. A permutation counts arrangements, so ABC and CBA are different. A combination counts selections, so both are the same pick. Choosing 2 from 6 gives 30 permutations and 15 combinations, and the factor of 2 between them is exactly 2!.
nPr = n! / (n - r)!. For 11 players choosing a captain and a goalkeeper, that is 11! / 9! = 11 x 10 = 110, since the captain cannot also be the keeper and leaves the pool once chosen.
nCr = n! / (r! x (n - r)!). Picking 2 strikers from 11 gives 11! / (2! x 9!) = 55. It is the permutation count divided by r!, because the r chosen players can be ordered in r! ways and those all count as one selection.
Because the order matters: 1-2-9 does not open a lock set to 2-9-1. A true combination would accept any order of those three numbers. The everyday word simply does not match the mathematical one.
That an item cannot be picked twice. Once a player is made captain they leave the pool, so the next choice has one fewer option. With replacement, every pick has the full set available, which is the case for a lock accepting 3-3-3 or a die rolled repeatedly.
There is exactly one way to arrange nothing, and the formulas require it. Setting r = n gives nPn = n! / 0!, which has to equal n!, and that only works if 0! is 1.
Two questions. Does swapping two of your picks change the outcome? If yes it is a permutation, if no it is a combination. Can the same item be picked twice? If yes use the with-replacement version. That gives four formulas, all shown in the table on this page.
Not without replacement. You cannot choose 5 items from a set of 3 when nothing can repeat, and the calculator reports that instead of returning a number. With replacement it is fine, since items can be reused.
For a 6-from-49 draw it is 1 in 49C6, which is 1 in 13,983,816. Order is ignored because the balls are sorted after the draw, so it is a combination rather than a permutation.
Because each step multiplies by a larger number. 10! is 3.6 million, 20! is about 2.4 x 10 to the 18th, and 70! exceeds the estimated number of atoms in the observable universe. This calculator uses arbitrary-precision integers so results stay exact, where ordinary calculators start approximating above 21!.