Uttir
By Uttir 6 min read

How to Calculate Permutations and Combinations (with Worked Examples)

A practical guide to counting: the difference between permutations (order matters) and combinations (order does not), the formula for each, the common real-world cases, and how to run the calculation in your browser without pulling out a calculator or a textbook.

A permutation is the number of ways to arrange r items from n when the order matters. A combination is the same count when the order does not matter. The formulas are n! / (n-r)! for permutations and n! / (r!(n-r)!) for combinations. For n=5, r=3: permutations = 60, combinations = 10. The most common mistake is using the wrong one — most real-world cases are combinations (a hand of cards, a lottery ticket, a committee), not permutations. A browser calculator handles the factorial math and the division in one place, so the result is instant and your numbers never leave the device.

Permutations and combinations are the most useful kind of math most people forgot the moment they left school. They show up in lotteries, password strength, committee selection, poker hands, scheduling, and the probability questions on every exam. This post covers the difference between the two, the formulas, the most common real-world cases, and how to run the math in your browser without a textbook or a TI-84.

Order matters vs. order does not: the core distinction

Both permutations and combinations count the number of ways to choose a subset of items from a larger set. The difference is whether the order of selection matters.

  • Permutation. Order matters. The arrangement A-B-C is different from C-B-A. Used for: race finishes, lock combinations (which are actually permutations despite the name), password strength, scheduling.
  • Combination. Order does not matter. The hand {A, K, Q} is the same as {K, Q, A} (alphabetical). Used for: poker hands, lottery tickets, committee selection, choosing toppings on a pizza.

The most common real-world mistake is using the wrong one. The most common real-world answer is a combination — most natural-language uses of "choose" and "select" do not care about order. The exceptions are race results, passwords, and any case where the order is the answer.

The formulas

Permutations (order matters)

P(n, r) = n! / (n − r)!

where n is the total number of items and r is how many you are choosing. The notation is sometimes written as nPr or P(n,r) or ^nP_r. All mean the same thing.

For n = 5 and r = 3:

P(5, 3) = 5! / (5 − 3)! = 5! / 2! = 120 / 2 = 60

That is, there are 60 ways to choose and arrange 3 items from a set of 5.

Combinations (order does not matter)

C(n, r) = n! / (r! × (n − r)!)

The notation is sometimes nCr or C(n,r) or ^nC_r. The relationship between permutations and combinations is:

C(n, r) = P(n, r) / r!

For n = 5 and r = 3:

C(5, 3) = 5! / (3! × 2!) = 120 / (6 × 2) = 120 / 12 = 10

That is, there are 10 ways to choose 3 items from a set of 5 when the order does not matter.

The difference between the two numbers (60 vs 10) is exactly r! = 6, which is the number of ways to arrange 3 items. The permutation counts each arrangement as distinct; the combination treats all arrangements of the same set as one.

Worked example: a poker hand

A standard poker hand is 5 cards from a 52-card deck, and the order does not matter. The number of distinct hands is C(52, 5) = 2,598,960. The number of distinct sequences (which would be the answer for a game where order matters, like rummy) is P(52, 5) = 311,875,200. The factor of 120 between them is exactly 5! (the number of ways to order 5 cards).

For poker, the combination number is the right one. For rummy, the permutation number is. The only difference is the game rules.

Worked example: lottery odds

Powerball picks 5 white balls from 69 and 1 red ball from 26. The order of the white balls does not matter. The number of distinct white-ball combinations is C(69, 5) = 11,238,513. The number of distinct Powerball tickets is 11,238,513 × 26 = 292,201,338. That is the published "1 in 292 million" odds. (The jackpot is split among all winners, which is why the expected value is usually negative even when the headline jackpot is large.)

Worked example: a 4-digit PIN

A 4-digit PIN has 10,000 possible values (0000 to 9999). The number of possible PINs is P(10, 4) = 5,040 if the digits cannot repeat, and 10^4 = 10,000 if they can. ATMs allow repeats, so the right number is 10,000. A thief who tries 3 PINs per second would need 3,333 seconds (about 55 minutes) to try them all. The "lock yourself out after 3 tries" rule is what makes PINs actually secure.

Worked example: a strong password

The strength of a password is the number of possible passwords, which is the size of the search space an attacker has to try. For a random password of length L drawn from a character pool of size C (e.g. C = 26 for lowercase, C = 62 for lowercase + uppercase + digits, C = 94 for all printable ASCII), the number of possibilities is C^L. This is not a permutation or combination, but it is the same family of counting problem.

For a 12-character random password from all printable ASCII: 94^12 ≈ 4.7 × 10^23. The Password Strength Checker computes this and converts it to a time-to-crack estimate.

Worked example: committee selection

You have 12 employees and need to pick a committee of 4. The number of distinct committees is C(12, 4) = 495. The number of ways to pick a president, vice president, secretary, and treasurer from the 12 is P(12, 4) = 11,880. The factor of 24 between them is 4! (the number of ways to order the four roles).

If the committee is just a committee (no roles), the combination is right. If the four people are taking on different roles, the permutation is right. The math is the same; the interpretation is different.

Worked example: race finishes

10 horses race, no ties. The number of possible win-place-show (top 3) orderings is P(10, 3) = 720. The number of possible top-3 sets (without regard to finish order) is C(10, 3) = 120. For an exacta bet (predict 1st and 2nd in order), the permutation is right. For a trifecta box (any order of 1st, 2nd, 3rd), the combination is right. The track takes a cut of the pool, which is why the expected payout is less than the headline.

The "n choose r" intuition

The combination C(n, r) is sometimes called "n choose r" because the most natural reading is "how many ways can I choose r items from n?" The answer is a single number that grows fast: C(10, 5) = 252, C(52, 5) = 2.6 million, C(100, 5) = 75 million. The growth is what makes most real-world "pick a random subset" problems easy to set up and hard to brute-force.

The Permutation / Combination Calculator handles the factorial math for any reasonable n and r. The browser-side implementation is what matters for large n (say, n = 1000), where the result is bigger than a JavaScript number can hold and needs an arbitrary-precision library. Most use cases are well under 100, so a standard number is fine.

Probability questions that use the same math

Most probability questions are combinations divided by total combinations. Examples:

  • Probability of a royal flush in poker. 4 royal flushes (one per suit) divided by 2,598,960 possible hands = 1 in 649,740.
  • Probability of being dealt a specific hand in bridge. 1 favorable hand divided by C(52, 13) = 1 in 635,013,559,600.
  • Probability of winning the lottery. 1 ticket divided by total possible tickets.

The general pattern: probability = (favorable outcomes) / (total outcomes). When order matters, the count is permutations; when order does not, the count is combinations. The Statistics Calculator is the right tool for the probability piece, and the permutation-combination tool is the right tool for the counting piece.

How to use the calculator

  1. Open the Permutation / Combination Calculator.
  2. Enter n (the total number of items, e.g. 52 for a deck of cards).
  3. Enter r (the number you are choosing, e.g. 5 for a poker hand).
  4. The calculator shows both P(n, r) and C(n, r), the factorial breakdown, and the interpretation in plain English ("60 ways to arrange, 10 ways to choose").

The whole calculation runs in the browser. The numbers you enter are in your input field, the math is JavaScript, and the result is rendered locally. No server, no log, no analytics on what you are counting.

A short checklist for picking the right one

  1. Does the order of selection matter? If yes, permutation. If no, combination.
  2. Are you choosing without replacement (e.g. a hand of cards from a deck) or with replacement (e.g. a PIN that can have repeated digits)? The formulas above assume without replacement. With replacement, the count is n^r.
  3. Are the items distinguishable? The formulas assume yes. For indistinguishable items (e.g. 5 red balls and 3 blue balls), the count is the multinomial, which is more complex.

For the common cases (cards, lotteries, committees, race finishes, passwords), the two formulas cover everything. For the unusual cases (multinomials, with-replacement, indistinguishable), the same calculator can be extended or a textbook consulted. The answer is one formula either way.

#permutation#combination#math#counting#probability#factorial

New tools and guides, once a week

One short email when something new ships. No tracking, no images, unsubscribe with one click.