Combination & Permutation Calculator
Calculate nCr and nPr with step-by-step factorial breakdown.
Reviewed by the ToolNestr Editorial Team — July 2026
What are combinations and permutations?
Combinations and permutations are two fundamental ways of counting selections from a set. The key difference is whether the order of selection matters. If order matters, we are dealing with permutations. If order does not matter, we are dealing with combinations.
Both concepts rely on the factorial function, written as n! and defined as the product of all positive integers from 1 up to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. By convention, 0! = 1.
Formulas
Permutations
nPr = n! / (n − r)!
Number of ways to arrange r items from n where the order of selection matters.
Combinations
nCr = n! / (r! × (n − r)!)
Number of ways to choose r items from n without regard to order.
Notice that permutations always produce a larger (or equal) value than combinations for the same n and r. This is because each combination of r items can be rearranged in r! different orders to produce distinct permutations. The relationship is: nPr = nCr × r!.
Worked example: n = 5, r = 3
Suppose you have 5 distinct items labelled A, B, C, D, and E, and you want to select 3 of them.
Permutations: 5P3 = 60
For the first position you have 5 choices. After picking one, 4 remain for the second position, then 3 for the third. Total arrangements = 5 × 4 × 3 = 60. The formula gives 5! / 2! = 120 / 2 = 60. Example arrangements: ABC, ABD, ABE, ACB, ACD, ACE, ADB, ADC, ADE, AEB, AEC, AED … (60 total).
Combinations: 5C3 = 10
From the 60 permutations, every set of 3 items appears in 3! = 6 different orders (e.g. ABC, ACB, BAC, BCA, CAB, CBA are all the same combination). Dividing 60 by 6 gives 10 distinct combinations: ABC, ABD, ABE, ACD, ACE, ADE, BCD, BCE, BDE, CDE.
Real-world use cases
Probability & Lottery Odds
The probability of winning a lottery is 1 divided by the number of possible combinations. If a lottery requires picking 6 numbers from 49, the total combinations are 49C6 = 13,983,816. Your chance of winning with one ticket is about 1 in 14 million. Combinations tell you how many possible outcomes exist when order does not matter — exactly the scenario for most lottery, bingo, and raffle games.
Password Cracking
A 4-digit PIN uses permutations because the order of digits matters: 1234 is different from 4321. With 10 digits (0–9) and 4 positions, the total permutations are 10P4 = 10 × 9 × 8 × 7 = 5,040. If digits could repeat, it would be 10⁴ = 10,000. Password security relies on these permutation counts — the more possible arrangements, the harder to crack.
Sports Brackets & Rankings
In a race with 8 runners, the number of ways to award gold, silver, and bronze medals is 8P3 = 336 — the order of the top three finishers matters. For selecting a 3-person committee from 8 candidates, order does not matter, so you use 8C3 = 56. Sports tournaments, chess rankings, and podium finishes all involve permutations.
Genetics & Bioinformatics
DNA sequences are permutations of four bases (A, T, G, C). A sequence of length 10 has 4¹⁰ = 1,048,576 possible permutations. When analysing gene combinations without regard to order — such as which genes are expressed — researchers use combinations. Combinatorial mathematics is the backbone of population genetics, protein folding analysis, and phylogenetic tree construction.
Important tips
r must be ≤ n
You cannot select more items than are available. If r > n, both nCr and nPr are undefined (zero). The calculator enforces this rule and will display an error.
nPr is always ≥ nCr
For the same n and r, permutations count every ordering separately, while combinations treat order as irrelevant. The ratio is exactly r! — each combination corresponds to r! distinct permutations.
Large values cause overflow
Factorials grow extremely fast. 170! is approximately 7.26 × 10³⁰⁶, which exceeds the maximum safe double-precision float (≈1.79 × 10³⁰⁸). The calculator checks for this and shows a warning when intermediate values approach the overflow threshold. For n > 170, you would need specialised arbitrary-precision libraries. This calculator handles n and r up to 170 with overflow protection.
When r = 0 or r = n
There is exactly one way to choose nothing (r = 0) or everything (r = n): nC0 = nCn = 1 and nP0 = nPn = 1. Choosing all items in a specific order gives n! permutations.
Symmetry of combinations
Combinations have a useful symmetry: nCr = nC(n−r). Choosing which 3 items to include from 5 is the same as choosing which 2 items to exclude. This property can simplify calculations when r is close to n.
Why factorial understanding matters
Foundation for probability theory
Every probability calculation involving equally likely outcomes reduces to counting favourable outcomes divided by total outcomes. Whether you are calculating the odds of a poker hand (52C5 = 2,598,960 possible hands), the chance of flipping exactly 3 heads in 5 coin tosses (5C3 / 2⁵ = 10/32), or the probability of a specific committee being formed, combinations and permutations are the essential counting tools. Mastering these concepts unlocks the entire field of discrete probability.
Computational considerations
Computing nCr directly via the formula n! / (r! × (n−r)!) can cause unnecessary overflow because n! may be enormous even when the final result is small (e.g., 100C1 = 100, but 100! is huge). For efficiency and accuracy, many implementations use the multiplicative formula: nCr = Πᵢ₌₁ʳ (n − i + 1) / i. This calculator uses the multiplicative approach to stay within safe numerical ranges and only computes factorials explicitly for the step-by-step breakdown display.
Related tools
- Quadratic Equation Solver — solve ax² + bx + c = 0 step by step.
- Logarithm Calculator — compute logarithms with any base.
Frequently asked questions
What is the difference between combinations and permutations?
Permutations consider order (ABC ≠ CBA), combinations do not (ABC = CBA).
What is nCr?
nCr = n! / (r! × (n−r)!). The number of ways to choose r items from n without regard to order.
What is nPr?
nPr = n! / (n−r)!. The number of ways to arrange r items from n where order matters.
When should I use combinations vs permutations?
Use combinations when order doesn't matter (lottery, committee selection) and permutations when it does (passwords, race rankings).