Skip to content

Permutations and Combinations Calculator

52C5

2,598,960

Step-by-step
  1. Formula: nCr = n! / (r!(n − r)!)
  2. = (48 × 49 × 50 × 51 × 52) / (1 × 2 × 3 × 4 × 5)
  3. = 2,598,960

Estimates for educational purposes — not financial, medical, or legal advice. See terms.

Compute the number of permutations (ordered arrangements) or combinations (unordered selections) of r items chosen from a pool of n. Uses BigInt arithmetic throughout so the answer is exact at any scale — no floating-point approximation, no overflow at 20! like regular numbers would give.

The formulas

Permutations — ordered arrangements:

nPr = n! / (n − r)! = n × (n − 1) × (n − 2) × … × (n − r + 1)

That’s r consecutive descending factors starting from n. Think of picking r people for 1st, 2nd, 3rd place: n choices for gold, (n−1) left for silver, (n−2) for bronze.

Combinations — unordered selections:

nCr = n! / (r!(n − r)!) = nPr / r!

The division by r! accounts for the r! different orderings of the same selection that would be double-counted by permutations. Combinations are also called “n choose r” and written C(n, r) or $\binom{n}{r}$.

Example: poker hands

How many distinct 5-card poker hands can be dealt from a 52-card deck? Order doesn’t matter in poker, so this is nCr with n = 52, r = 5.

52C5 = 52 × 51 × 50 × 49 × 48 / (5 × 4 × 3 × 2 × 1) = 311,875,200 / 120 = 2,598,960

There are 2,598,960 distinct poker hands. For context: there are 4 possible royal flushes (one per suit) and 40 straight flushes total, which is why those hands are so rare (40 / 2,598,960 ≈ 1 in 65,000).

Example: lottery odds

UK National Lottery: draw 6 balls from 49. Single ticket has 49C6 = 13,983,816 distinct possible outcomes. Odds of winning with a single ticket: 1 in ~14 million. Knowing the number helps put lottery marketing in perspective — the expected value of a £2 ticket is near-zero regardless of the jackpot size, because the probability of winning is vanishingly small.

Example: PIN codes

How many 4-digit PINs are there? If digits can repeat (which they can in real PINs), it’s 10⁴ = 10,000. If they can’t repeat, it’s a permutation: 10P4 = 10 × 9 × 8 × 7 = 5,040. The “no repeats” version removes about half the space, so “my PIN has no repeated digits” cuts the entropy significantly — one reason security-conscious password advice is the opposite of the no-repeats rule.

Example: seating arrangements

How many ways can 8 people sit in 8 chairs? That’s 8! = 40,320 (this is nPn = n!). How many ways if there are only 3 chairs and the other 5 people stand? 8P3 = 336. If we don’t care who stands vs. sits (just which 3 we pick), it’s 8C3 = 56 — exactly 336 / 6 = 336 / 3!.

Why BigInt

Factorials grow very fast. For reference:

  • 10! = 3,628,800
  • 13! = 6,227,020,800 — last one representable in a 32-bit signed int
  • 18! = 6,402,373,705,728,000 — last one exact in a 64-bit float (≤ 2⁵³)
  • 21! = 51,090,942,171,709,440,000 — exceeds Number.MAX_SAFE_INTEGER
  • 52! = 8.07 × 10⁶⁷ — the number of orderings of a 52-card deck

For anything beyond about n = 20, regular JavaScript numbers lose precision and return approximations. BigInt handles integers of any size exactly, at the cost of slower arithmetic — but at the scales we’re talking about (computing a single combination or permutation), that doesn’t matter. The tool uses BigInt throughout and formats the result with thousands separators.

The falling-factorial trick

Rather than computing n! first and then dividing by (n − r)!, the tool uses the multiplicative formula:

nPr = n × (n − 1) × … × (n − r + 1)

This loop runs r times, not n times, and never builds up the full factorial. For n = 100 and r = 5, we multiply 100 × 99 × 98 × 97 × 96 = 9,034,502,400 directly, without ever touching the 158-digit value of 100!. Same idea for combinations: multiply the r numerator terms and the r denominator terms, then divide — all BigInt, all exact.

What this tool does not do

It doesn’t handle “with replacement” — when the same item can be picked multiple times. For that you’d use n^r (ordered with replacement) or C(n + r − 1, r) (unordered with replacement, the “stars and bars” formula). This tool only handles the without-replacement case, which is the more common textbook meaning.

It doesn’t compute multinomial coefficients — distributing n items into k bins of specified sizes. That’s a generalisation of nCr to multiple groups (n! / (r₁! r₂! … rₖ!)). For that use a multinomial calculator.

It doesn’t enumerate the actual arrangements — it counts them. Generating every permutation or every combination is a different problem (and the result sets are usually too large to be useful anyway — 52C5 has 2.6 million elements). For random selection from a range without enumerating the full set, the random number generator does draws with or without replacement.

It doesn’t handle negative or non-integer n / r. Combinatorics only makes sense for non-negative integers; the tool rejects fractional and negative inputs.

It doesn’t compute binomial probabilities — P(k successes in n trials with probability p) = C(n, k) p^k (1−p)^(n−k). The tool gives you the C(n, k) piece, but the probability requires multiplying by the power terms.

Frequently asked questions

What's the difference between permutations and combinations?

Permutations count ordered arrangements; combinations count unordered selections. If you're picking 3 letters from {A, B, C, D} and order matters (ABC, ACB, BAC, ... are all different), that's permutations — 4P3 = 24 arrangements. If order doesn't matter (ABC and CBA are the same selection), that's combinations — 4C3 = 4 selections. The ratio nPr / nCr is always r!, reflecting the r! ways to order each selected group.

Why does the tool use BigInt?

Because factorials explode fast. JavaScript's regular Number can only represent integers exactly up to 2⁵³ (about 9 × 10¹⁵), and 18! already exceeds that. If we used regular numbers, even moderate inputs like 52C5 = 2,598,960 would be fine, but 52! = 8 × 10⁶⁷ would return a rounded float approximation. BigInt gives exact integer arithmetic at arbitrary size, so 100C50 (a 30-digit number) is computed exactly with no approximation. The tradeoff is that the result is a BigInt, which can't be mixed with regular numbers without explicit conversion — but since we only display it as a string, that's invisible.

What's the real-world meaning of 52C5?

The number of distinct 5-card poker hands you can deal from a standard 52-card deck — 2,598,960. Order doesn't matter in poker (the dealt cards are what they are regardless of the sequence). If order did matter — say, the sequence of cards you'd draw off the top — that'd be 52P5 = 311,875,200, exactly 120× larger (which is 5!, the number of orderings of 5 cards). Combinatorics shows up constantly in card games, lottery odds, and probability problems.

What are some common combinatorics values?

49C6 = 13,983,816 — the number of possible 6-ball lottery draws from 49 balls (UK National Lottery). 52C5 = 2,598,960 — poker hands. 52C13 = 635,013,559,600 — bridge hands. 10P3 = 720 — three-digit PIN codes with no repeats. 26P3 = 15,600 — three-letter sequences from the alphabet with no repeats. These and similar 'how many ways to...' questions are exactly what nPr and nCr are designed to answer.

What's the boundary behaviour?

When r = 0, both nPr and nCr equal 1 — there's exactly one way to choose or arrange nothing (the empty set / empty arrangement). When r = n, nPr = n! (all n! orderings) and nCr = 1 (only one way to pick everything). When r > n, both are 0 — you can't choose more items than you have, and the tool rejects this as a domain error rather than returning 0 silently. When n = r = 0, both equal 1 (the empty case, consistent with 0! = 1).