Does the order matter?
This one question decides everything. If the order matters, you count permutations. If it does not, you count combinations.
A lock code or a race result is a permutation, because 1-2-3 and 3-2-1 are different outcomes. A team or a lottery ticket is a combination, because the same names make the same team in any order. A quick test: swap two of your picks. If the answer changes, order matters.
The formulas
nCr = n! ÷ ( r! × (n − r)! )
- n = how many things you choose from
- r = how many you choose
- ! = factorial, for example 5! = 5 × 4 × 3 × 2 × 1
- ⁿPᵣ = number of permutations (order matters)
- ⁿCᵣ = number of combinations (order does not matter)
Pick 3 people from 10. As a permutation (say president, secretary, treasurer) there are 10 × 9 × 8 = 720 ways. As a combination (just a committee of 3) there are 720 ÷ 6 = 120, because every group of 3 can be shuffled in 3! = 6 orders and a combination counts it only once.
When repeats are allowed
If an item can be used again, nothing gets used up, so every pick has all n choices. The number of ordered picks is nr. A 4-digit PIN has 10 choices for each digit, so there are 10⁴ = 10,000 PINs.
For unordered picks with repeats the formula is (n + r − 1)! ÷ ( r! × (n − 1)! ). Choosing 3 scoops from 5 flavours, repeats allowed: C(7, 3) = 35.
A famous example
A lottery where you choose 6 numbers out of 49 is a combination, since the order of the balls does not matter. The number of tickets is C(49, 6) = 13,983,816. That is why the odds are about 1 in 14 million.