Combination calculator
Choosing five cards from fifty-two where order does not matter gives 2,598,960 possible hands. If order did matter it would be 311,875,200. Exactly 120 times more, because five cards can be arranged in 5! = 120 ways. That factor of r! is the entire difference between a combination and a permutation, and it is why nCr is always the smaller number.
A combination counts selections where order does not matter: C(52,5) = 2,598,960 possible poker hands. A permutation counts arrangements where it does: P(52,5) = 311,875,200, exactly 5! times more. The same panel gives factorials to 170, and the with-repetition counts for when an item can be picked twice.
How to count combinations
The four numbers here cover every counting situation, and picking the right one comes down to two questions. Does order matter? And can an item be chosen more than once? A lottery draw is combinations without repetition. A four-digit PIN is arrangements with repetition, which is why there are 10,000 of them and not 5,040. A podium finish is permutations without repetition. Getting the wrong one is by far the most common error in counting problems.
A podium is not a padlock
Three medals among ten runners is 720, because nobody wins twice. A three-wheel padlock with ten digits on each is 1,000, because the wheels are independent. Same n, same r, larger answer. It is also why a combination lock is named misleadingly: order matters very much, so it is a permutation lock.
The two counts are directly related. nPr equals nCr times r!, because every unordered selection of r items can itself be ordered r! ways. That is the quickest sanity check on either figure, and it explains why nCr is always the smaller of the two. nCr is also symmetric: choosing 3 of 10 to include is the same act as choosing 7 to leave out, so C(10,3) and C(10,7) are both 120.
Factorials get out of hand quickly
Underneath all four counts is the factorial, which earns its own tab because the numbers run away so fast. 10! is 3,628,800; 20! is 2,432,902,008,176,640,000; 52! is about 8 × 10⁶⁷, more than the estimated number of atoms in the Milky Way. Zero factorial is defined as one, which looks arbitrary and is not: n! = n × (n−1)! applied at n = 1 gives 1! = 1 × 0!, so 0! has to be 1. The same definition makes C(n,n) come out as one way to choose everything, which is the only answer it could have.
Past about 20 the exact digits stop being the interesting part and the size takes over. Stirling’s approximation, n! ≈ √(2πn) × (n∕e)ⁿ, gives it directly: at n = 10 it returns 3,598,696 against a true 3,628,800, low by 0.83 per cent, and the relative error shrinks as n grows. It is why serious code almost never holds n! itself but log(n!), which stays a modest number long after n! has stopped fitting into anything.
What people use it for
- Lottery and card odds
- Counting possible passwords or PINs
- Committee or team selection problems
- Counting race, podium or ranking outcomes
- Seating and ordering problems
- Estimating the size of a search space
- Seeing how fast factorial growth really is
- Probability coursework
Questions
Order. Combinations treat ABC and CBA as the same selection; permutations count them separately, so nPr is nCr times r!.
2,598,960, which is C(52,5).
n! divided by r!(n−r)!. It is also the binomial coefficient, the entries of Pascal triangle.
n! divided by (n−r)!, the number of ordered arrangements of r items from n.
Ten thousand. 10⁴, because digits can repeat and order matters.
For ordered selection it becomes n to the power r. Ten digits over three wheels gives 1,000.
720, since order matters and nobody wins twice.
No. Order matters, so it is a permutation lock; the name is a long-standing misnomer.
Because choosing r items is the same as choosing which n−r to leave out. C(52,5) equals C(52,47).
3,628,800.
Because n! = n × (n−1)! requires it, and because there is exactly one way to arrange nothing.
About 8 × 10⁶⁷: more than the estimated number of atoms in the Milky Way.
Twelve. Every trailing zero needs a factor of five paired with a two, and twos are far more plentiful, so the fives do all the limiting: ⌊52∕5⌋ + ⌊52∕25⌋ = 10 + 2.
Stirling’s formula, √(2πn) × (n∕e)ⁿ. It is 0.83 per cent low at n = 10 and better above that.
Not directly. The gamma function extends factorials to non-integers, where Γ(n+1) = n!.
Because 171! overflows a double-precision float: 170! is about 7.3 × 10³⁰⁶ and the next step is infinity. Beyond that you need arbitrary-precision arithmetic.