Combinations Calculator C(n,k)
Count unordered selections of k items chosen from n distinct items.
C(n,k), also written as "n choose k", counts unordered subsets of size k drawn from n distinct items.
How is this calculated?
Formula: C(n, k) = n! / (k! (n - k)!). To avoid intermediate overflow this tool uses the symmetry C(n, k) = C(n, n - k) and the recurrence C(n, k) = product over i in 1..k of (n - k + i) / i with BigInt division. Source: standard combinatorics; see Pascal's triangle.
What is the Combinations Calculator?
The Combinations Calculator computes C(n, k), the binomial coefficient, which is the number of unordered ways to choose k items from a set of n distinct items. The defining formula is C(n, k) = n! divided by k! times (n minus k)!.
Combinations answer "how many groups of k can I form from n", treating {A, B} and {B, A} as the same group. The calculator above accepts n up to 1000 and returns the exact integer using JavaScript BigInt arithmetic so very large coefficients like C(1000, 500) are not lost to floating-point rounding. Scientific notation and digit count are shown alongside for orientation.
How the formula works
The factorial form is mathematically clean but explodes quickly: 100! has 158 digits. The product form is what the tool actually evaluates, multiplying k integers and dividing by k integers in lockstep with BigInt, so intermediate values stay bounded by the final answer. Source: Rosen, Discrete Mathematics and Its Applications (8th ed.), Section 6.3.
Worked example: poker hands
How many distinct 5 card hands can be dealt from a standard 52 card deck? Plug n = 52 and k = 5.
- Numerator: 52 times 51 times 50 times 49 times 48 = 311,875,200.
- Denominator: 5! = 5 times 4 times 3 times 2 times 1 = 120.
- C(52, 5) = 311,875,200 / 120 = 2,598,960.
- Cross check with symmetry: C(52, 5) = C(52, 47). Both return the same value.
Reference table of common combinations
| Use case | n | k | C(n, k) |
|---|---|---|---|
| Coin flip outcomes (5 heads in 10 flips) | 10 | 5 | 252 |
| Lottery: 6 of 49 | 49 | 6 | 13,983,816 |
| Powerball white balls: 5 of 69 | 69 | 5 | 11,238,513 |
| Poker hand: 5 of 52 | 52 | 5 | 2,598,960 |
| Bridge hand: 13 of 52 | 52 | 13 | 635,013,559,600 |
| Pick 3 from 10 finalists | 10 | 3 | 120 |
| Central binomial coefficient C(20,10) | 20 | 10 | 184,756 |
Common pitfalls
- Confusing C with P. Permutations P(n, k) count ordered arrangements. C(n, k) = P(n, k) / k!. Use combinations when order does not matter (committee membership, card hands), permutations when it does (race finishing order, password characters).
- Repetition allowed. The standard formula assumes distinct items, no replacement. For combinations with replacement use C(n + k - 1, k) (multiset coefficient).
- Off-by-one with "at least" and "exactly". The probability of "at least 3 heads in 5 flips" sums C(5, 3) + C(5, 4) + C(5, 5), not just C(5, 3).
- Float overflow. Pure JavaScript Number arithmetic loses precision above 2^53. Always use BigInt for n above 50 or so.
- Negative or non integer inputs. C(n, k) is defined only for non negative integers with 0 less than or equal k less than or equal n. The calculator rejects other inputs.
When to use combinations
- Probability calculations: coin flips, dice, lottery odds, hypergeometric distributions.
- Combinatorial counting: committee picks, team rosters, menu selections, password classes.
- Binomial distribution: the C(n, k) factor is the leading term in P(X = k) for n Bernoulli trials.
- Algorithm analysis: counting subsets, paths in grids, and dynamic programming state spaces.
Related calculators and references
Frequently asked questions
What is the difference between a combination and a permutation?
How is the binomial coefficient calculated?
What is Pascal's triangle?
Are repetitions allowed in C(n,k)?
Why use BigInt for large combinations?
What is C(n, 0) and C(n, n)?
Sources
- Rosen, Kenneth H. (2018). Discrete Mathematics and Its Applications, 8th edition, McGraw Hill, Section 6.3.
- Graham, Knuth and Patashnik (1994). Concrete Mathematics, 2nd edition, Addison Wesley, Chapter 5.
- NIST Digital Library of Mathematical Functions, 26.3 Binomial Coefficients.
- Mozilla Developer Network, BigInt reference.
