Permutations and Combinations Calculator
Enter n (total items) and r (items chosen) to instantly get n!, nPr (permutations), and nCr (combinations) with the formula worked out for your exact numbers. Factorials also show up when you break a number into its building blocks with the prime factorization calculator or find shared factors with the LCM and GCF calculator, and once you've counted your outcomes the standard deviation calculator can help measure how spread out a set of results is.
n! (Factorial)
nPr — Permutations
order matters
nCr — Combinations
order doesn't matter
Formulas With Your Numbers
Real-World Example — Permutation
Real-World Example — Combination
Permutations vs. Combinations: What's the Difference?
Both permutations and combinations count the number of ways to select r items from a set of n items — the only question is whether order matters.
Permutations count arrangements where order matters. Choosing a 3-digit PIN from the digits 0–9 is a permutation: the codes 123 and 321 use the same three digits but are completely different PINs. Combinations count selections where order does not matter. Choosing 3 fruits from a basket of 10 for a snack is a combination: grabbing an apple, then a banana, then a grape gives you the exact same snack as grabbing the grape first — the order you picked them up in is irrelevant.
A simple rule of thumb: if rearranging the chosen items would give you a different result (a different code, a different ranking, a different seating), use a permutation. If rearranging them gives you the exact same outcome (the same group, the same hand of cards, the same team roster), use a combination.
The Formulas Explained
Why nPr = n! / (n − r)!
Imagine filling r ordered slots from n available items. There are n choices for the first slot, n − 1 remaining choices for the second slot, n − 2 for the third, and so on, down to n − r + 1 choices for the last slot. Multiplying those choices together gives n × (n−1) × (n−2) × … × (n−r+1). Writing that as a ratio of factorials — where the tail end of n! from (n−r)! down to 1 cancels out — gives the compact formula:
nPr = n! / (n − r)!
Why nCr = nPr / r!
A combination is just a permutation with the ordering thrown away. For any group of r chosen items, there are exactly r! different ways to arrange (order) that same group — and every one of those r! orderings gets counted separately inside nPr. To get the number of distinct groups rather than distinct orderings, divide out those duplicates:
nCr = nPr / r! = n! / (r! × (n − r)!)
This is also why nCr is always smaller than (or equal to) nPr for the same n and r — combinations collapse every group of r! equivalent orderings down to a single count.
What Is 0! (Zero Factorial)?
By convention, 0! = 1. This can feel odd at first, but it comes from the idea of an "empty product" — multiplying zero numbers together leaves you with the multiplicative identity, 1, the same way adding zero numbers together leaves you with 0. There's also exactly one way to arrange zero items: doing nothing. Defining 0! = 1 is what keeps the nPr and nCr formulas working cleanly at the edges. For example, when r = n, (n − r)! = 0! = 1, so nPr = n! / 1 = n! — every full arrangement of all n items — which is exactly what we'd expect.
Frequently Asked Questions
Why is 0! equal to 1?
It's a mathematical convention based on the "empty product" rule: multiplying no numbers together yields 1 (the identity for multiplication), just as adding no numbers together yields 0. Defining 0! = 1 also keeps formulas like nPr = n! / (n − r)! and nCr = n! / (r! × (n − r)!) consistent at the boundary cases r = 0 and r = n, without needing special-case exceptions.
What's a real-world example of when order doesn't matter?
Lottery numbers and committee selection are classic combination examples. If a lottery draws 6 numbers from 1–49, the numbers {3, 17, 22, 28, 35, 44} win regardless of the order they were physically drawn in — that's a combination, nCr. Likewise, choosing a 5-person committee from a group of 20 people is a combination: the committee is the same group of 5 no matter which order you happened to pick them in.
How large can n get before this calculator has trouble?
JavaScript's number type starts losing exact integer precision once a value exceeds 253 (about 9.007 × 1015), which happens for n! once n reaches about 19. This calculator computes nPr and nCr using iterative products (rather than dividing two enormous factorials) to stay as accurate as possible for as long as possible, and it clearly labels any result above that safe-integer threshold as an approximate value shown in scientific notation instead of silently rounding a huge number and pretending it's exact. Once n climbs past roughly 170, n! itself overflows to infinity in double-precision floating point, and the calculator will say so rather than display a wrong number.
Is choosing a starting lineup in sports a permutation or combination?
It depends on whether the positions are distinct. If you're picking 5 players from a roster of 12 to be on the court with no assigned positions, that's a combination — the group of 5 is what matters. But if you're assigning those 5 specific positions (point guard, shooting guard, center, and so on), it becomes a permutation, because swapping two players between two different positions creates a genuinely different lineup.
How are permutations used in password/PIN security?
Permutations are exactly what determines how many possible passwords or PINs exist, which is the basis for measuring "brute-force" difficulty. A 4-digit PIN using digits 0–9 with repetition allowed has 104 = 10,000 possibilities, but a 4-digit PIN where every digit must be different is a permutation: 10P4 = 10 × 9 × 8 × 7 = 5,040 possibilities. In general, longer passwords and larger allowed character sets both increase the permutation count exponentially, which is why security guidance pushes for length and variety — each additional character multiplies the number of possible permutations an attacker would have to try.
What's the difference between "n choose r" notation and nCr?
They're the same thing written two different ways. "n choose r," written as C(n, r) or with the binomial coefficient notation (n over r) in a stacked column, is identical to nCr — the number of ways to choose r unordered items from n. You'll see all of these notations used interchangeably in textbooks, calculators, and probability formulas.