TOOLTIKI Lovable tool, really free

Does order matter, and can it repeat?

Every counting problem reduces to two questions. Does the order matter, and can an item appear twice? Answer both and the formula follows. Three medals among ten runners is 720 ways, because order matters and nobody wins twice; a three-wheel padlock with ten digits is 1,000, because order matters and digits repeat.

Get those two wrong and the answer is out by orders of magnitude rather than by a rounding.

Which formula for which question?

The four cases, with n items and r chosen.

Order matters Repetition Formula Example
Yes No n! ÷ (n−r)! Podium: P(10,3) = 720
Yes Yes Padlock: 10³ = 1,000
No No n! ÷ (r!(n−r)!) Poker hand: C(52,5) = 2,598,960
No Yes (n+r−1)! ÷ (r!(n−1)!) Scoops of ice cream

The poker case is the clearest illustration of why order matters so much. There are 2,598,960 possible five-card hands and 311,875,200 ordered deals of five cards — exactly 120 times more, because 5! = 120 orderings of every hand.

How fast does a factorial grow?

Faster than almost anything else you will meet. 10! is 3,628,800; 20! already exceeds two quintillion; 52! is about 8 × 10⁶⁷.

That last figure is the reason a shuffled deck is almost certainly unique in history. There are more orderings of 52 cards than there are atoms in the observable universe by many orders of magnitude, so any well-shuffled deck has, with overwhelming probability, never existed before.

Zero factorial is defined as one, which looks arbitrary and is not. It falls straight out of the recursive definition n! = n × (n−1)!: applying it at n = 1 gives 1! = 1 × 0!, so 0! must be 1 for the identity to hold.

What breaks a probability calculation?

Independence, almost always. Probability is favourable outcomes over total outcomes, and for independent events both happening is the product of the two — but the formula only holds while the events genuinely are independent.

Two dice are independent; two cards drawn without replacement are not, because the first draw changes what is left. Applying the product rule to the second case gives an answer that is close enough to look right and is wrong.

The at-least-one calculation is where the product rule earns its keep: the probability of at least one success in n tries is 1 minus the probability of none, which is 1 − (1−p)ⁿ. That is far easier than summing the cases, and it is the correct approach to almost every "what are the chances it happens at least once" question.

Why does at-least-once surprise people?

Because it grows much faster than intuition suggests. An event with a 1 in 100 chance per attempt has a 63 per cent chance of happening at least once in 100 attempts, not a certainty and not a small number.

The general result is that at n = 1/p the probability of at least one occurrence converges on 1 − 1/e, about 63.2 per cent, whatever p is. That single figure covers a great many "surely it would have happened by now" arguments.

It is also the same arithmetic behind the coverage problem in random picking, which the picker article works through from the other direction.

The birthday problem is the best-known illustration of how badly intuition performs here. In a room of 23 people the chance that two share a birthday is just over 50 per cent, because there are 253 pairs rather than 23 people — the count that matters is of comparisons, not of participants.

Where does the counting go wrong in practice?

Three specific places.

  1. Treating a combination as a permutation, which overstates by r!.
  2. Forgetting repetition is allowed, which understates badly for anything with independent positions.
  3. Assuming independence between draws that affect each other.

The diagnostic is to state the problem as a sentence containing the words "order" and "again". If the sentence is hard to write, the formula is not the thing that is unclear.

Questions people ask

Why is a lottery combination and not a permutation? Because the balls are read back in sorted order — the draw sequence does not matter. That is why the odds are C(49,6) rather than P(49,6), a factor of 720 more forgiving.

Is 0! = 1 a convention? It is forced by the recursive definition and by the combination formula, both of which break without it. It is derived rather than chosen.

What about arrangements with repeated items? Divide by the factorial of each repeat count. The letters of BANANA arrange in 6! ÷ (3! × 2!) = 60 ways rather than 720.

How large can a factorial get before it overflows? 20! is the largest that fits in a signed 64-bit integer. Beyond that, exact values need arbitrary precision and approximations use Stirling’s formula.

Does the birthday problem need 366 people for certainty? For a guarantee, yes — 367 with leap days. For a coin-flip chance, 23 is enough, which is the gap between certainty and probability that the problem exists to illustrate.

Why does the deck argument need 52 factorial? Because every ordering is a distinct shuffle, and 52! counts them all. The number is large enough that no two properly shuffled decks in history are likely to have matched.

Two questions, four formulas, and the rest is arithmetic. The permutation and combination calculators cover both order cases with and without repetition, the factorial calculator handles the growth underneath them, and the probability calculator applies the results to independent events and at-least-once questions.