Mathematics · Probability & Statistics
Permutation and Combination Calculator
Calculates the number of permutations P(n,r) and combinations C(n,r) for selecting r items from a set of n distinct items.
Calculator
Formula
n is the total number of distinct items in the set. r is the number of items being selected or arranged. P(n,r) counts ordered arrangements (permutations), where the order of selection matters. C(n,r) counts unordered selections (combinations), where only the chosen group matters, not the sequence. The exclamation mark (!) denotes the factorial function: n! = n × (n−1) × (n−2) × … × 1, with 0! defined as 1.
Source: Rosen, K.H. (2011). Discrete Mathematics and Its Applications, 7th Edition. McGraw-Hill. Chapter 6: Counting.
How it works
Permutations vs. Combinations — The Core Distinction
The essential question is: does order matter? If you are assigning three runners to gold, silver, and bronze medals from a group of ten athletes, the order of selection matters — awarding gold to Alice and silver to Bob is different from awarding gold to Bob and silver to Alice. This is a permutation problem. Conversely, if you are simply choosing three people to form a committee where all members are equal, only the group composition matters — this is a combination problem. Understanding which situation applies is the first and most important step in any counting problem.
The Formulas in Detail
The permutation formula is P(n, r) = n! / (n − r)!, which counts all distinct ordered sequences of length r drawn from n items. The combination formula is C(n, r) = n! / [r! × (n − r)!], which divides out the r! orderings of each group because those orderings are considered identical. C(n, r) is also called the binomial coefficient and written as "n choose r." Both formulas rely on the factorial function: n! is the product of all positive integers from 1 to n, with 0! = 1 by convention. Note that C(n, r) = P(n, r) / r!, which directly shows how combinations are permutations with the ordering removed.
Practical Applications
Permutations appear in problems involving passwords, PIN codes, race rankings, scheduling, and any scenario where sequence matters. Combinations appear in lottery odds, card hand probabilities, team selection, survey sampling, and statistical hypothesis testing. The binomial coefficient C(n, r) also appears directly in the binomial theorem, Pascal's triangle, and probability distributions such as the binomial and hypergeometric distributions. Engineers use these formulas when analyzing fault-tolerant systems; data scientists use them when evaluating feature subset selections; financial analysts use them when modelling portfolio compositions.
Worked example
Example 1 — Permutation (Podium Finishes)
A race has 8 runners. How many distinct ways can the gold, silver, and bronze medals be awarded? Here n = 8 and r = 3, and order matters.
P(8, 3) = 8! / (8 − 3)! = 8! / 5! = (8 × 7 × 6 × 5!) / 5! = 8 × 7 × 6 = 336 ordered arrangements.
Example 2 — Combination (Committee Selection)
A company has 8 employees and needs to select 3 to form an equal-standing project committee. Order does not matter.
C(8, 3) = 8! / (3! × 5!) = (8 × 7 × 6) / (3 × 2 × 1) = 336 / 6 = 56 unique committees.
Key Insight: Both examples use the same n = 8 and r = 3, yet yield very different answers: 336 permutations versus 56 combinations. The ratio is exactly 3! = 6, because each group of 3 people can be arranged in 6 different ordered sequences.
Example 3 — Lottery Odds
A lottery requires matching 6 numbers drawn from 49. The number of possible tickets is:
C(49, 6) = 49! / (6! × 43!) = (49 × 48 × 47 × 46 × 45 × 44) / (6 × 5 × 4 × 3 × 2 × 1) = 13,983,816 / 720 … wait — numerator = 49 × 48 × 47 × 46 × 45 × 44 = 10,068,347,520; divided by 720 = 13,983,816 possible combinations, giving a 1-in-13,983,816 chance of winning.
Limitations & notes
This calculator requires that n and r are non-negative integers and that r ≤ n. Fractional or negative inputs are mathematically undefined for standard factorials. Due to floating-point limits, values of n above 170 cause factorial overflow (170! ≈ 7.26 × 10^306, the maximum representable double-precision float), so results for very large n are not supported. For extremely large values, consider using logarithms of factorials (Stirling's approximation) or a dedicated arbitrary-precision library. This calculator also handles only selections without replacement from a set of distinct items; if items are repeated or replacements are allowed, different formulas apply (e.g., permutations with repetition = n^r, combinations with repetition = C(n + r − 1, r)). Always confirm that your real-world problem maps correctly to either the ordered or unordered selection model before interpreting results.
Frequently asked questions
What is the difference between a permutation and a combination?
A permutation is an ordered arrangement — the sequence in which items are selected matters. A combination is an unordered selection — only which items are chosen matters, not the order. For example, selecting {A, B, C} and {C, A, B} count as two different permutations but the same combination. Mathematically, P(n, r) = r! × C(n, r), so permutations always equal or exceed combinations.
How do I know whether to use P(n,r) or C(n,r) for my problem?
Ask yourself: if I swap the order of my selected items, do I get a different outcome? If yes, use permutations. If no, use combinations. Medal standings, PIN codes, and ranked lists require permutations. Committee selections, card hands, and lottery tickets require combinations. When in doubt, try listing a small example — if {A, B} and {B, A} are counted separately, use P(n, r).
Why is 0! equal to 1?
0! = 1 is a convention that keeps factorial-based formulas consistent. For example, C(n, 0) should equal 1 because there is exactly one way to choose nothing from a set — the empty selection. Substituting into the formula: C(n, 0) = n! / (0! × n!) = n! / (1 × n!) = 1, which only works if 0! = 1. The definition also extends naturally from the recursive relationship n! = n × (n−1)!, applied at n = 1: 1! = 1 × 0! implies 0! = 1.
What is the binomial coefficient and how does it relate to combinations?
The binomial coefficient, written as C(n, r) or "n choose r" (notated with a binomial bracket), is exactly the combination formula n! / [r!(n − r)!]. It appears in the binomial theorem: (a + b)^n = sum of C(n,k) × a^(n−k) × b^k. It also forms Pascal's triangle, where each entry equals the sum of the two entries directly above it. In probability, C(n, r) gives the number of ways to get exactly r successes in n independent Bernoulli trials.
How do permutations and combinations apply to probability calculations?
In classical probability, the probability of an event equals (number of favorable outcomes) / (total number of possible outcomes). Combinations and permutations are used to count both. For example, the probability of being dealt a flush in five-card poker is C(13,5) × 4 / C(52,5) = 1287 × 4 / 2,598,960 ≈ 0.00198, or about 0.2%. The denominator uses C(52,5) because card hands are unordered selections. Permutations would be used if the order cards are dealt affected the outcome.
Last updated: 2025-01-15 · Formula verified against primary sources.