Calculate permutations and combinations for probability
Permutations and combinations both count the number of ways to select items from a group, but permutations count arrangements where order matters, while combinations count selections where order doesn't matter. They're foundational to probability, statistics, and combinatorics problems.
Permutations: nPr = n! / (n − r)! | Combinations: nCr = n! / (r! × (n − r)!)
A permutation counts arrangements where order matters (like 1st, 2nd, 3rd place); a combination counts selections where order doesn't matter (like picking 3 people for a team) — the same group counted as multiple permutations collapses into a single combination.
5! (5 factorial) = 5 × 4 × 3 × 2 × 1 = 120 total arrangements, since this is a permutation of all 5 items taken 5 at a time.
nCr = n! / (r! × (n−r)!). For example, choosing 3 people from a group of 8: 8! / (3! × 5!) = 56 possible combinations.
Use permutations whenever the order or arrangement matters to the outcome — like assigning distinct roles, ranking results, or forming passwords — and combinations when you're only choosing a group or subset with no ranking involved.
By mathematical convention, 0! is defined as 1 so that formulas like nPr and nCr work correctly even when there's exactly one way to arrange zero items (doing nothing).