Math Runs locally Ready to use Built-in examples No tracking

Permutation & Combination Calculator

Enter n and k to get combinations, permutations, powers and factorials with formulas.

How many five-card hands are there in a 52-card deck? Counting by hand is hopeless, but the formula takes one line — and the difficulty is never the arithmetic, it is deciding whether order matters. Choosing a committee is a combination; awarding gold, silver and bronze is a permutation. Enter n and k and all four counts come back with the formula written beside each one.

Combinations C(n, k) ignore order, permutations P(n, k) respect it, and n^k allows repetition (as in passwords, where every position can be reused); the identity C(n, k) = P(n, k) ÷ k! links the first two. Results grow extremely fast — 52 choose 5 is already 2,598,960 — so this tool uses arbitrary-precision arithmetic and falls back to scientific notation for very large values.

—
—
—
—

How to use

  1. Enter the total number of items (n) and how many are chosen (k).
  2. Read C(n, k), P(n, k), n^k and the factorial, each with its formula.
  3. Decide from the wording of the question whether order matters before picking a result.
  4. Copy the value; very large results are also given in scientific notation.

How it works

Combination vs. permutation

The combination C(n,k) = n! / (k!(n−k)!) only cares which items are chosen, ignoring order; the permutation P(n,k) = n! / (n−k)! also cares how they are ordered, so P(n,k) = C(n,k) × k!. Example: choosing 3 people from 10 for a committee is C(10,3) = 120 ways; choosing 3 and assigning chair, vice-chair and secretary is P(10,3) = 720.

Why big numbers never lose precision

Results are computed exactly with integers (BigInt). Already 20! = 2,432,902,008,176,640,000 exceeds the largest integer JavaScript's double precision can represent exactly (2^53, about 9×10^15) — plain floats would corrupt the last digits. Combination counts also outrun intuition: C(52,5) = 2,598,960, C(100,3) = 161,700. The tool caps n at 500 to keep result lengths sane (500! has 1,135 digits).

Typical values and scenarios

Typical scenarios for the three counts: n^k counts selections with replacement — a 4-digit PIN has 10^4 = 10,000 codes, 3 coin flips have 2^3 = 8 outcome sequences; combinations cover raffles, team picks and poker hands (five cards from 52: C(52,5) = 2,598,960); permutations cover rankings, relay orders and seating.

Calculation basis: combinations C(n,k) = n!/(k!(n−k)!), permutations P(n,k) = n!/(n−k)! and permutations with repetition n^k. All factorials and counts are computed exactly with integers (BigInt), and n is capped at 500.

Code example

JavaScript Combinations and permutations safe for large numbers

function C(n, k) {                 // combinations: the multiplicative form avoids huge factorials
  k = Math.min(k, n - k);
  let r = 1;
  for (let i = 1; i <= k; i++) r = r * (n - k + i) / i;
  return Math.round(r);
}
const P = (n, k) => C(n, k) * factorial(k);

C(49, 6);    // 13983816 (a 49-ball lottery)
C(52, 5);    // 2598960 (a 5-card poker hand)

Python Built-in math.comb and math.perm

import math

math.comb(49, 6)     # 13983816 (combinations, Python 3.8+)
math.perm(49, 6)     # 10068347520 (permutations)
math.factorial(10)   # 3628800

# Big numbers work natively (arbitrary-precision integers):
math.comb(1000, 500)   # exact, no overflow

FAQ

What exactly differs between C and P?

Order. A combination only selects; a permutation selects and arranges, and P(n,k) = C(n,k) × k!. The two coincide when k = 1 or k = n (e.g. C(5,1) = P(5,1) = 5).

When do I use a combination?

Whenever the chosen group is unordered: raffles, picking team members, poker hands, sampling for inspection. The moment roles or sequence matter — rankings, PINs, relay order — switch to permutations. This is the step most often confused.

Why is C(52,5) equal to 2598960?

Five cards from 52 without order: 52! / (5! × 47!) = (52×51×50×49×48) / 120 = 311,875,200 / 120 = 2,598,960 — the total number of five-card poker hands.

How big is 20 factorial?

2,432,902,008,176,640,000 — about 2.43×10^18 (19 digits). It exceeds the 2^53 exact-integer limit of double precision, so floating-point arithmetic would corrupt the last digits; exact integer arithmetic is required, which is why this tool uses BigInt.

What is the largest n? What if k exceeds n?

n is capped at 500 (beyond that results grow unwieldy — 500! has 1,135 digits). k cannot exceed n: "choosing 5 from 3" is mathematically meaningless, and the tool says so directly.

What is n^k for?

It counts selections with replacement: a 4-digit PIN has 10^4 = 10,000 codes; 3 coin flips have 2^3 = 8 sequences. It is the third common counting method alongside permutations and combinations — and the most often misapplied.

Are the computations recorded or uploaded?

No. n and k are multiplied locally in your browser as integers — nothing is uploaded, nothing is tracked. History lives only in this browser, clears with one click, and disappears when an incognito window closes.