Distributions
Permutations and Combinations Calculator
How many ways there are — with order mattering or not, and with repetition allowed or not.
Also called permutation calculator, combination calculator, nCr and nPr calculator, factorial calculator.
How to read this result
Order is the only question that matters. If ABC and CBA count as different results, you want a permutation. If they are the same selection, you want a combination. Everything else follows.
There are exactly r! times as many permutations as combinations, because each selection of r items can be arranged r! ways. That is why the combination formula is the permutation formula divided by r!.
Repetition changes both. Choosing 3 from 5 without repetition gives 10 combinations; with repetition, 35. The second is C(n + r − 1, r), and it is the right count for questions like "how many ways can I fill three scoops from five flavours".
Everything is computed in log space. C(1000, 500) is about 2.7 × 10²⁹⁹ and a formula written directly with factorials fails at n = 171, where 171! overflows a double. Nothing here is computed as a ratio of factorials.
The formula
- the number of items to choose from
- the number being chosen
With repetition allowed: nʳ permutations and C(n + r − 1, r) combinations.
Worked example
The odds on a 6-from-49 lottery
A lottery draws six numbers from forty-nine. Order does not matter and no number repeats. How many possible tickets are there?
- Order-sensitive count first: 49 choices, then 48, and so on for six picks.P(49,6) = 49 × 48 × 47 × 46 × 45 × 44 = 10,068,347,520
- Each set of six numbers has been counted once for every ordering of those six.6! = 720
- Divide.C(49,6) = 10,068,347,520 / 720 = 13,983,816
- So one ticket wins with probability 1 in 13,983,816.p = 7.15 × 10⁻⁸
Buying a ticket every week gives you an expected wait of about 268,000 years for a jackpot. The counting is the easy part; the intuition is what the number is for.
Checked against R's choose(49, 6) and factorial(49)/factorial(43).
The calculator above is loaded with these numbers by the Load the worked example button.
Assumptions, and when to use something else
The items must be distinguishable, and the counting rules assume every arrangement is equally likely if you go on to turn a count into a probability.
Two situations are commonly mishandled. Identical items — arranging the letters of MISSISSIPPI — need the multinomial coefficient, which divides by the factorial of each repeat count. And circular arrangements have (n − 1)! orderings rather than n!, because rotations are equivalent.
- You want a probability from the countProbability calculatorFavourable arrangements divided by total arrangements.
- Counting successes in repeated trialsBinomial distributionThe binomial coefficient here is the first factor of that distribution.
- You are drawing without replacement and want probabilitiesProbability calculatorThe hypergeometric situation, where each draw changes the pool.
Questions people ask
What is the difference between a permutation and a combination?
Order. A permutation counts arrangements — first, second and third place in a race. A combination counts selections — which three people are on a committee. There are always r! times as many permutations as combinations.
What does nCr mean?
“n choose r” — the number of combinations of r items from n, also written C(n, r) or as the binomial coefficient. It is the button labelled nCr on a scientific calculator.
How large can n be here?
Very. Everything is computed as an exponential of log-gamma, so C(5000, 2500) — a number with about 1,500 digits — is reported in scientific notation rather than overflowing. A formula using factorials directly fails at n = 171.
How do I count arrangements with repeated letters?
Divide n! by the factorial of each repeat count. MISSISSIPPI has 11 letters with four I's, four S's and two P's, giving 11!/(4!·4!·2!) = 34,650 distinct arrangements. That multinomial case is not in the calculator above, but the arithmetic is the same idea.