Compute exact binomial coefficients C(n,k) = n!/(k!(n-k)!) using arbitrary-precision arithmetic. Visualize Pascal's Triangle, discover combinatorial identities, and apply to probability, algebra, and discrete mathematics.
Click any cell to auto-fill n and k. The triangle displays binomial coefficients C(row, col). Rows are zero-indexed.
In mathematics, the binomial coefficient C(n,k) (read "n choose k") counts the number of ways to choose an unordered subset of k elements from a fixed set of n distinct elements. It is fundamental in combinatorics, probability, algebra, and number theory. The standard notation uses \(\binom{n}{k}\) and is defined by:
\(\displaystyle \binom{n}{k} = \frac{n!}{k!\,(n-k)!}\)
where \(n! = n \times (n-1) \times \cdots \times 1\) and \(0! = 1\).
Binomial coefficients appear in the binomial theorem: \((x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k\). They also arise in probability distributions (binomial distribution), combinatorial identities (Vandermonde, hockey-stick), and the construction of Pascal's triangle.
Unlike standard calculators that overflow or round floating-point results, our tool uses JavaScript BigInt to compute exact integer values for virtually any n up to several hundreds (limited by browser memory). It also provides a live Pascal’s Triangle visualizer, allowing interactive exploration. This is invaluable for students verifying combinatorial proofs, researchers analyzing sequences, and professionals implementing probability models.
The odds of winning a typical 6/49 lottery require computing \(\binom{49}{6}\). Using our calculator: n=49, k=6 → 13,983,816 possible combinations. This means the probability of a single ticket matching all numbers is 1 in ~14 million. Such analysis is central to risk assessment, gambling mathematics, and game design. Our tool instantly gives exact combinations without any approximation error.
Our algorithm runs in O(k) time with BigInt multiplication and division. For n up to 500, results appear instantly. At n = 1000, C(1000,500) contains about 300 digits and computes within a few hundred milliseconds on modern hardware. Values beyond n = 1500 are possible but may cause noticeable delay; we recommend keeping n ≤ 1000 for interactive use.
function binomial(n, k) {
if (k < 0 || k > n) return 0n;
if (k === 0 || k === n) return 1n;
let kk = Math.min(k, n - k);
let res = 1n;
for (let i = 1; i <= kk; i++)
res = res * BigInt(n - kk + i) / BigInt(i);
return res;
}
This pattern is memory efficient and avoids intermediate factorial overflow – ideal for combinatorial computing in browsers or Node.js.
| n | k | C(n,k) digit length | Approximate size |
|---|---|---|---|
| 200 | 100 | 59 digits | ~9.05×10⁵⁸ |
| 500 | 250 | 149 digits | ~6.16×10¹⁴⁸ |
| 1000 | 500 | 299 digits | ~2.70×10²⁹⁸ |
| n | k | C(n,k) | Interpretation |
|---|---|---|---|
| 5 | 2 | 10 | Ways to choose 2 from 5 |
| 10 | 4 | 210 | Number of 4-element subsets |
| 20 | 10 | 184756 | Central coefficient |
| 52 | 5 | 2,598,960 | Poker hand combinations |
| 100 | 50 | 100891344545564193334812497256 | Extremely large binomial |
The concept of binomial coefficients has been known for centuries. Ancient Indian mathematicians (Pingala, 3rd century BCE) described what would become Pascal's triangle. Persian mathematician Al-Karaji (10th century) and later Omar Khayyam studied binomial expansions. In Europe, Blaise Pascal (17th century) formalized the arithmetical triangle and its properties, leading to modern combinatorics. Today they are omnipresent in computational biology, cryptography, and algorithm analysis.