Combination Calculator

Calculate C(n, k) = n!

Science Exact BigInt
Rate this calculator · 4.0 (2)

Combination Calculator

Exact BigInt · combinations + permutations

Instructions — Combination Calculator

A combination counts the number of ways to choose k items from n distinct items when order does not matter.

  1. Enter n, the total number of items.
  2. Enter k, the number you want to choose. The constraint is 0 ≤ k ≤ n.
  3. Read C(n, k), the matching permutation P(n, k), and the "1 in N" odds (useful for lottery problems).

The calculator uses BigInt arithmetic to give exact results for n up to a few thousand and falls back to log approximation beyond that.

Formulas

Combinations count selections; permutations count arrangements.

Combination: $$ C(n, k) = \binom{n}{k} = \frac{n!}{k! (n - k)!} $$

Permutation (for comparison): $$ P(n, k) = \frac{n!}{(n - k)!} $$ The relationship is $P(n, k) = C(n, k) \times k!$.

Symmetry: $$ C(n, k) = C(n, n - k) $$ The number of ways to choose k items equals the number of ways to leave out k items.

Pascal's rule: $$ C(n, k) = C(n-1, k-1) + C(n-1, k) $$ This recursion builds Pascal's triangle row by row.

Reference

Real-world examples for popular C(n, k) values:

ProblemC(n, k)Value
Lottery 6/49C(49, 6)13,983,816
Poker hand (5 of 52)C(52, 5)2,598,960
Team selection (11 of 23)C(23, 11)1,352,078
Committee (4 of 10)C(10, 4)210
Powerball (5 of 69)C(69, 5)11,238,513
EuroMillions (5 of 50)C(50, 5)2,118,760
Yahtzee (3 of 5 dice)C(5, 3)10

Pascal's triangle arranges combination values in rows: row n contains C(n, 0), C(n, 1), …, C(n, n). The triangle has been documented by Yang Hui (1261), Al-Karaji (~1000 AD), and others long before Pascal published it in 1654.

Article — Combination Calculator

Combination Calculator: C(n, k) = n! / (k!(n − k)!)

A combination counts how many ways k items can be chosen from n distinct items when order does not matter. The combination formula is C(n, k) = n! / (k! · (n − k)!). For lottery 6/49, C(49, 6) = 13,983,816. For poker, C(52, 5) = 2,598,960 five-card hands from a standard deck. The combination calculator uses exact BigInt arithmetic to give precise results without overflow.

Combinations are the workhorse of counting problems whenever order is irrelevant: lottery odds, sample selections, team rosters, committee assembly, and probability of specific card hands. The math is simple but easy to misapply.

What a combination is

The defining feature of a combination is that order does not matter. Choosing players A, B, and C for a team is the same selection as B, A, C or C, B, A. If the order of selection were meaningful (gold medal, silver medal, bronze medal), that would be a permutation.

For combinations, every distinct subset of size k counts once. For an n-element set, the count of all k-element subsets is the binomial coefficient, written either as C(n, k) or as the "n choose k" notation in brackets.

The combination formula

Combination formula
C(n, k) = n! / (k! · (n−k)!) main formula
C(n, k) = C(n, n−k) symmetry
C(n, 0) = C(n, n) = 1 boundary cases

The numerator n! counts ordered arrangements of all n items. The denominator divides out the k! orderings of the chosen items (since order does not matter) and the (n − k)! orderings of the unchosen items. What remains is the count of distinct selections.

Direct computation through factorials overflows quickly. For n = 50, n! has 65 digits. The combination calculator uses BigInt arithmetic and a multiplicative formula C(n, k) = (n × (n−1) ×... × (n−k+1)) / k! that avoids constructing the full factorials.

Combination versus permutation

The permutation P(n, k) counts ordered arrangements: P(n, k) = n! / (n − k)!. The relationship between the two is P(n, k) = C(n, k) × k!, since each combination of k items can be ordered in k! different ways.

ConceptFormulaExample: choose 3 from 5
CombinationC(n, k) = n! / (k! · (n−k)!)C(5, 3) = 10
PermutationP(n, k) = n! / (n−k)!P(5, 3) = 60

A permutation always has at least as many outcomes as a combination for the same n and k. They are equal only when k = 0 or k = 1.

Worked combination examples

Lottery odds. In a 6/49 lottery, players choose 6 numbers from 49. The number of equally likely tickets is C(49, 6) = 13,983,816. The probability of matching all six is 1 / 13,983,816, or about 7 × 10−8. Powerball uses 5/69 (C(69, 5) = 11,238,513 outcomes for the five white balls).

Poker hands. A standard 52-card deck has C(52, 5) = 2,598,960 distinct five-card hands. Of these, exactly 4 are royal flushes, 36 are straight flushes (excluding royals), 624 are four-of-a-kind, and 3,744 are full houses. Probabilities are computed as (count of favorable hands) / C(52, 5).

Sports. Selecting a starting lineup of 11 from a squad of 23 gives C(23, 11) = 1,352,078 possible lineups, ignoring positional roles. With positions distinguished (one goalkeeper, four defenders, etc.), the count is much smaller, but the raw combination shows the upper bound.

Did you know

Pascal's triangle predates Pascal by at least 600 years. Yang Hui documented it in China in 1261, Al-Karaji described it in Persia around 1000 AD, and Omar Khayyam wrote about it in the 11th century. Tartaglia published it in Europe in 1556, nearly a century before Pascal's 1654 work. Pascal earned the naming because of his rigorous mathematical treatment, especially applications to probability theory.

Combinations in probability

The binomial distribution uses combinations directly. If a trial succeeds with probability p, the probability of exactly k successes in n independent trials is C(n, k) · pk · (1−p)n−k. The C(n, k) factor counts the number of ways the k successes can be arranged among the n trials.

Combinations also drive hypergeometric probabilities (sampling without replacement) and many counting problems in statistical inference. Anywhere you have to count favorable outcomes from a fixed set without caring about order, C(n, k) is the right tool.

Pascal's triangle and combinations

Pascal's triangle is the table of combination values: row n contains C(n, 0), C(n, 1), …, C(n, n). Each value is the sum of the two above it, expressing the recurrence C(n, k) = C(n−1, k−1) + C(n−1, k).

The triangle reveals patterns: the sum of row n equals 2n, every row reads the same forward and backward (symmetry of combinations), and prime values appear in regular positions. The numbers also appear as coefficients in the binomial expansion (a + b)n = Σ C(n, k) ak bn−k.

  • C(0, 0) = 1 — the empty selection from an empty set
  • C(n, 0) = C(n, n) = 1 — only one way to choose nothing or everything
  • Sum of row n in Pascal's triangle = 2n (total number of subsets)
  • C(n, k) = C(n, n−k) — symmetry, useful for computation
  • C(2n, n) grows as the central binomial coefficient, ≈ 4n / √(πn)

Combinations with replacement

When items can be picked more than once, the formula changes. Combinations with replacement (sometimes called multicombinations) use C(n + k − 1, k). Example: choosing 3 ice cream scoops from 5 flavors when repeats are allowed gives C(5 + 3 − 1, 3) = C(7, 3) = 35 possible orders (treating "chocolate, chocolate, vanilla" as one selection).

Tip

Most introductory problems use combinations without replacement, which is what the standard C(n, k) formula computes. Double-check the problem statement: is each item drawn from a different position (no replacement) or can the same item appear twice (with replacement)? The right formula depends entirely on this distinction.

Common combination mistakes

Order matters or not?

The most common error is using a permutation when a combination is needed (or vice versa). If the problem assigns distinct roles (positions, prize levels, ranks), order matters — use permutation. If everyone selected just becomes part of an unordered group (members of a team, items in a sample), order does not matter — use combination.

Other regular mistakes: trying k > n (the formula returns 0 since you cannot choose more than you have), forgetting that C(n, 0) = 1, and computing factorials directly instead of using the multiplicative shortcut, which causes overflow for moderately large n.

FAQ

In a combination, order does not matter; selecting {A, B} is the same as {B, A}. In a permutation, order matters; (A, B) and (B, A) are different. P(n, k) = C(n, k) × k!, so permutations are always at least as numerous as combinations for the same n and k.
For a draw of k numbers from n total, the number of equally likely outcomes is C(n, k). The chance of matching all numbers is 1 / C(n, k). A 6/49 lotto gives C(49, 6) = 13,983,816 possible tickets, so the odds of one matching ticket are 1 in 13,983,816.
Yes. Selection with replacement (multicombinations) uses C(n + k − 1, k). The plain C(n, k) assumes no replacement — each item can be chosen at most once.
Pascal's triangle is the array of values C(n, k) arranged so that each entry is the sum of the two above it. Row n gives the coefficients in the binomial expansion (a + b)n. It has been studied since at least 1000 AD.
Use logarithmic computation: log C(n, k) = log n! − log k! − log (n − k)!. This avoids overflow. For moderately large n, BigInt arithmetic gives exact results.
C(0, 0) = 1. There is exactly one way to choose nothing from nothing — the empty selection. This convention makes Pascal's triangle and the binomial theorem consistent.
Choosing which k items to include is mathematically the same as choosing which n − k items to leave out. Both decisions partition the n items into the same two groups, just labelled differently. This symmetry also speeds up computation: use the smaller of k and n − k.
Many discrete probability problems reduce to counting favorable outcomes and dividing by total outcomes, where both counts involve combinations. Card hands, lottery, sampling without replacement, and the binomial distribution all use C(n, k) as their core.