Permutations, Combinations, and Basic Probability
Telling arrangement problems apart from selection problems, applying the nPr and nCr formulas, and computing basic probability.
What you'll learn
- Determine whether a counting problem requires a permutation (order matters) or a combination (order doesn't matter)
- Apply the nPr and nCr formulas to count arrangements or selections
- Compute basic probability as favorable outcomes divided by total outcomes
Prerequisites
Explanation
Factorial notation (n!) means multiply every whole number from n down to 1: 5! = 5×4×3×2×1 = 120. By convention, 0! = 1 (there's exactly one way to arrange zero items — do nothing). Factorials show up everywhere in counting because they represent "the number of ways to arrange n distinct items in a row."
The single question that decides which formula to use: does order matter?
- If order matters (who's first, second, third — different orders count as different outcomes), it's a permutation: nPr = n! / (n − r)!, the number of ways to arrange r items chosen from n, in order.
- If order doesn't matter (just which items are chosen, not their sequence), it's a combination: nCr = n! / (r! × (n − r)!), the number of ways to choose r items from n, ignoring order.
Worked example (permutation). From 5 finalists, how many ways can 1st, 2nd, and 3rd place be awarded? Order clearly matters here — being 1st is different from being 2nd. nPr = 5P3 = 5!/(5−3)! = 5×4×3 = 60.
Worked example (combination). From the same 5 finalists, how many ways can a 3-person committee be chosen (no distinct roles, just membership)? Order doesn't matter now — the committee {A, B, C} is the same committee no matter which order they were picked in. nCr = 5C3 = 5!/(3!×2!) = (5×4×3)/(3×2×1) = 60/6 = 10. Notice nCr is always nPr divided by r! — because for every unordered group of r items, there are r! different orderings of that same group, all of which nPr would have counted separately.
Basic probability measures how likely a specific outcome is: P(event) = (number of favorable outcomes) / (total number of possible outcomes), assuming every outcome is equally likely. Rolling a standard fair six-sided die, P(rolling an even number) = 3 favorable outcomes (2, 4, 6) / 6 total outcomes = 1/2 = 0.5.
Worked example (probability using combinations). A bag contains 5 red and 3 blue marbles (8 total). Two marbles are drawn together at random. What's the probability both are red? Total ways to choose any 2 marbles from 8 is 8C2 = 28. Favorable ways to choose 2 red marbles from the 5 available is 5C2 = 10. So P(both red) = 10/28 ≈ 0.3571. This is a common pattern: whenever a probability problem involves choosing a group of items at once (not one at a time with replacement), combinations are usually how you count both the favorable and total outcomes.
Permutation vs combination at a glance
Permutation (nPr): order matters, formula n!/(n-r)!, example -- assigning 1st/2nd/3rd place among finalists. Combination (nCr): order does not matter, formula n!/(r!(n-r)!), example -- choosing an unranked committee of members.
Example
This iterative form of nCr keeps every intermediate result an exact integer, avoiding rounding drift.
function nCr(n, r) {
let result = 1;
for (let i = 0; i < r; i++) {
result = (result * (n - i)) / (i + 1);
}
return Math.round(result);
}
// Example: nCr(5, 3) -> 10Guided exercise
Guided exercise
Write nPr(n, r) that returns the number of ways to arrange r items chosen from n distinct items, in order, using the formula n! / (n - r)! (computed as a product of r descending terms starting from n, to avoid computing large factorials directly).
Checks: Computes a typical permutation count · Computes a permutation where r equals n · plus 1 hidden check
Code editor. Press Escape then Tab to leave the editor if keyboard focus becomes trapped. Press Control+Shift+M inside the editor to toggle Tab-key focus trapping.
Stuck? Get a hint.
Independent exercise
Independent exercise
Write probabilityBothSameColor(redCount, blueCount, wantColor) modeling drawing 2 marbles together at random from a bag of redCount red and blueCount blue marbles. wantColor is either 'red' or 'blue'. Return the probability both drawn marbles are wantColor, rounded to 4 decimal places, using combinations: (ways to choose 2 of wantColor) / (ways to choose 2 from the total).
Checks: Computes probability for the majority color · Computes probability for the minority color · plus 1 hidden check
Code editor. Press Escape then Tab to leave the editor if keyboard focus becomes trapped. Press Control+Shift+M inside the editor to toggle Tab-key focus trapping.
Stuck? Get a hint.
Common mistakes
- Using the permutation formula (nPr) for a problem where order genuinely doesn't matter, such as choosing an unranked committee, which overcounts every group r! times.
- Treating 0! as 0 instead of 1, which breaks combination and permutation formulas whenever r equals n or r equals 0.
- Computing 'at least one' probability by directly counting favorable outcomes instead of using 1 minus the probability of the complementary ('none') event, which is usually far simpler.
Knowledge check
Takeaway
Whether order matters decides everything -- permutations count ordered arrangements, combinations count unordered selections, and basic probability is just favorable outcomes over total outcomes once you've counted correctly.
Summary
Factorial notation underlies both permutations (nPr = n!/(n-r)!, order matters) and combinations (nCr = n!/(r!(n-r)!), order doesn't matter), with nCr always equal to nPr divided by r! since each unordered group corresponds to r! orderings. Basic probability divides favorable outcomes by total outcomes, and combinations often provide the correct way to count both when a problem involves selecting a group at once.
Your notes
Notes save automatically.
Finished this lesson?
Mark it complete to track your progress and schedule a future review.
AI tutor
The optional AI tutor isn't enabled in this deployment. All lessons, exercises, quizzes, and search work fully without it.