Audited 25 May 2026·Last updated 27 Jul 2026·5 citations·Tier 1·0 uses

Binomial Coefficient Calculator

Calculate binomial coefficients C(n,k) and permutations P(n,k). Accurate combinatorics calculator for probability, statistics, and algebra courses.

Binomial Coefficient Calculator

Total number of distinct items in the set
Number of items to choose without replacement
Binomial Coefficient
120
Exact number of ways to choose k items from n
Permutations P(n,k)
720

Background.

A binomial coefficient calculator computes the exact number of ways to choose k elements from a set of n distinct elements without regard to order. This quantity, written as C(n,k) or "n choose k," is the foundational counting function of combinatorics and appears in virtually every branch of mathematics that deals with discrete structures. Students encounter it first in probability courses when counting poker hands, lottery combinations, and committee memberships. Researchers rely on it in statistical mechanics when enumerating microstates, in machine learning when expanding kernel feature spaces, and in genetics when modeling allele combinations under Hardy-Weinberg equilibrium.

The practical importance of binomial coefficients extends far beyond textbook exercises. In cryptography, the binomial distribution governs the Hamming-weight properties of error-correcting codes. In finance, binomial trees model the evolution of asset prices under the Cox-Ross-Rubinstein framework, where each time step branches into up and down states whose probabilities sum to one. The number of paths reaching a given terminal node is exactly C(n,k), making the coefficient central to option pricing. In algorithm analysis, binomial coefficients describe the running time of recursive procedures and the growth rates of certain dynamic-programming tables.

Historically, the systematic study of these numbers dates to Blaise Pascal's 1654 treatise on the arithmetic triangle, though Indian mathematicians such as Pingala (c. 200 BCE) and later Halayudha had described similar triangular arrangements of binomial sums centuries earlier. Yang Hui's triangle, published in 1261, also predates Pascal by nearly four centuries. The coefficients derive their modern name from the binomial theorem, which states that (a + b)^n expands into a sum of terms whose coefficients are precisely C(n,k). Newton generalized this to non-integer exponents in 1665, creating the infinite series that underlie modern calculus.

The computational challenge lies in exactness. For n = 52 and k = 5—the classic five-card poker hand—the coefficient is 2,598,960, a value that fits comfortably in a 32-bit integer. However, for n = 100 and k = 50, the result exceeds 1e29, well beyond 32-bit range but still exactly representable as a JavaScript number up to n = 170. Beyond that threshold, IEEE-754 double-precision floats lose integer precision, producing rounded results that are useless for exact combinatorial work. The calculator therefore caps n at 170 and implements a multiplicative algorithm that divides at each iteration, preventing intermediate overflow that would occur in naive factorial computation.

In contemporary data science, binomial coefficients underpin feature selection algorithms, bootstrap resampling methods, and the structure of neural network architectures. They appear in the combinatorial explosion of decision trees, the enumeration of possible board states in game theory, and the calculation of Shapley values in explainable artificial intelligence. The coefficient also governs the expansion of generating functions used to solve recurrence relations in algorithm design and determines the number of parameters in polynomial regression models of fixed degree. As data sets grow larger and models become more complex, the need for exact combinatorial computation remains as urgent today as it was in Pascal's era, forming a cornerstone of reproducible quantitative research.

What is binomial coefficient calculator?

The binomial coefficient C(n,k) is the number of distinct k-element subsets that can be formed from an n-element set. It is defined for non-negative integers n and k with k ≤ n. The canonical formula is C(n,k) = n! / [k!(n − k)!], where n! denotes the factorial of n. By convention, 0! = 1, which ensures that C(n,0) = C(n,n) = 1 for every n ≥ 0. The coefficient satisfies several identities that simplify computation and reveal structural properties. Symmetry states that C(n,k) = C(n,n − k), reflecting the fact that choosing k elements to include is equivalent to choosing n − k elements to exclude. Pascal's identity, C(n,k) = C(n − 1,k − 1) + C(n − 1,k), provides a recursive construction that generates Pascal's triangle. The sum of binomial coefficients across a fixed row n equals 2^n, the total number of subsets of an n-element set. Units are dimensionless: the coefficient counts discrete objects and carries no physical dimension. It is always an integer, a fact that is not immediately obvious from the factorial formula but follows because the product of k consecutive integers is always divisible by k!. This integrality is essential in combinatorial proofs and in applications such as polynomial expansion where fractional coefficients would be meaningless.

How to use this calculator.

  1. Enter the total number of distinct items, n, in the first input field.
  2. Enter the number of items to choose, k, in the second input field.
  3. Ensure k is less than or equal to n and both values are non-negative integers.
  4. Click calculate to display the binomial coefficient C(n,k).
  5. Review the permutations value P(n,k) shown as secondary output.
  6. Use the result for probability calculations, polynomial expansion, or combinatorial enumeration.

The formula.

C(n,k) = n! ⁄ [ k!(n−k)! ]

The factorial definition C(n,k) = n! / [k!(n − k)!] follows directly from the multiplication principle of counting. To select k ordered elements from n, there are n choices for the first, (n − 1) for the second, and so on down to (n − k + 1) for the kth. This yields n! / (n − k)! ordered arrangements, or permutations P(n,k). Because each unordered subset of size k can be arranged in k! different orders, we divide by k! to eliminate the overcounting, leaving exactly C(n,k) distinct subsets. While mathematically elegant, the factorial form is computationally hazardous. Computing n! explicitly produces astronomical intermediate values; 170! exceeds 7e306, near the limit of double-precision floating point. For n = 171, 171! overflows to Infinity in JavaScript. Even when the final quotient C(n,k) is well within range, the intermediate factorials may not be. The multiplicative algorithm solves this by distributing the division across the multiplication sequence: C(n,k) = ∏_{i=1}^{k} (n − k + i) / i. At each step i, the running product is multiplied by the next numerator term and immediately divided by i. Because the exact value of C(n,k) is an integer, the intermediate result after each step is also rational with denominator dividing the final coefficient; in practice, the floating-point representation stays exact up to n = 170 because all intermediate values are integers smaller than the final result. Dimensional analysis confirms the coefficient is dimensionless: factorials count discrete objects, and the ratio of counts is a pure number. The boundary conditions C(n,0) = C(n,n) = 1 are consistent with the convention that there is exactly one way to choose nothing and one way to choose everything. The recurrence relation C(n,k) = C(n − 1,k − 1) + C(n − 1,k) underlies dynamic-programming implementations and explains the additive structure of Pascal's triangle. For large n, Stirling's approximation provides an asymptotic estimate, but the calculator returns exact integers because combinatorial applications require precision.

A worked example.

Example

A standard deck contains 52 distinct playing cards. To compute how many distinct five-card poker hands exist, we evaluate C(52,5) because the order in which cards are dealt does not matter for the hand classification. Using the multiplicative algorithm, the calculation proceeds as (52 × 51 × 50 × 49 × 48) / (5 × 4 × 3 × 2 × 1). The numerator equals 311,875,200. The denominator equals 120. Dividing yields 2,598,960. This means there are exactly 2,598,960 unique five-card combinations from a full deck. In Texas Hold'em, this is the denominator for the probability of any specific hand type; for example, the probability of being dealt a royal flush is 4 / 2,598,960 ≈ 0.00000154. The exactness of this integer is essential because rounding errors in the denominator would propagate into incorrect probability estimates. Professional poker strategy guides, tournament rule books, and academic probability texts all cite this same canonical value.

k5
n52

Frequently asked questions.

What is the difference between C(n,k) and P(n,k)?
The binomial coefficient C(n,k) counts unordered subsets: choosing Alice and Bob is the same as choosing Bob and Alice. The permutation P(n,k) counts ordered arrangements: Alice-then-Bob is distinct from Bob-then-Alice. Mathematically, P(n,k) = n! / (n − k)! while C(n,k) divides this by an additional k! to remove the internal ordering of the chosen set. For n = 5 and k = 2, P(5,2) = 20 but C(5,2) = 10. In probability, use C(n,k) when sampling without replacement and without order, and P(n,k) when order matters, such as ranking finalists or assigning distinct roles.
Why does the calculator use a multiplicative formula instead of computing factorials directly?
Direct factorial computation overflows at n = 171 in JavaScript, where 171! exceeds Number.MAX_VALUE and becomes Infinity. Even for smaller n, the intermediate factorial values are far larger than the final coefficient, causing unnecessary loss of precision. The multiplicative form C(n,k) = ∏ (n − k + i) / i keeps intermediate values bounded by the final result itself and never exceeds the exact integer representability limit of double-precision floats up to n = 170. This approach is standard in numerical libraries such as the NIST Digital Library of Mathematical Functions and in Knuth's Art of Computer Programming, Volume 1, which explicitly recommends iterative multiplication with early division for binomial coefficients.
What is Pascal's triangle and how does it relate to binomial coefficients?
Pascal's triangle is a triangular array in which each entry is the sum of the two entries directly above it. The nth row contains the coefficients C(n,0) through C(n,n). This structure follows from Pascal's identity, C(n,k) = C(n − 1,k − 1) + C(n − 1,k). The triangle has been studied independently in multiple cultures: Yang Hui published it in 1261, and it appeared in the work of the Indian mathematician Halayudha around 975. Beyond combinatorics, the triangle encodes the powers of 11, the Fibonacci sequence along diagonals, and the coefficients of binomial expansion. It remains a pedagogical tool because it visualizes the additive recurrence that underlies exact integer computation.
Can binomial coefficients be computed for non-integer n?
The standard combinatorial definition applies only to non-negative integers n and k. However, the factorial formula can be extended to real and complex n through the gamma function: C(n,k) = Γ(n + 1) / [Γ(k + 1) Γ(n − k + 1)]. This generalization appears in the binomial series expansion of (1 + x)^n for non-integer n, which Newton introduced in 1665. The calculator does not implement gamma-function generalization because its primary use cases—combinatorics, probability, and algebra—require integer arguments. Users seeking generalized binomial coefficients for real n should use a gamma-function calculator or computer algebra system.
What are the largest values this calculator supports?
The calculator supports n up to 170 with exact integer results. C(170,85) = 1.5835...e50, which is the largest binomial coefficient fitting exactly in a JavaScript number because the 53-bit mantissa of IEEE-754 doubles preserves all integers up to 9.007e15, but the exactness property for factorial quotients holds further due to the multiplicative algorithm's integer intermediates up to this bound. For n = 171, some coefficients exceed 1.797e308 and overflow to Infinity. Engineering caps n at 170 to guarantee exactness. Users requiring larger coefficients need arbitrary-precision integer libraries such as BigInt, which the current TypeScript target of ES2017 supports via the BigInt constructor.
How are binomial coefficients used in probability theory?
Binomial coefficients form the probability mass function of the binomial distribution. If an experiment with success probability p is repeated n times independently, the probability of exactly k successes is C(n,k) p^k (1 − p)^{n − k}. The coefficient counts the number of distinct sequences containing k successes and n − k failures. This distribution underlies hypothesis testing for proportions, quality-control acceptance sampling, and genetic inheritance models. The sum of all C(n,k) p^k (1 − p)^{n − k} over k from 0 to n equals 1, confirming that the distribution is properly normalized. This result follows from the binomial theorem with a = p and b = 1 − p.
What is the symmetry property of C(n,k)?
The symmetry property states that C(n,k) = C(n,n − k). Choosing k elements to include in a subset is equivalent to choosing n − k elements to exclude. Algebraically, the factorial formula yields n! / [k!(n − k)!] = n! / [(n − k)!k!], which is identical under interchange of k and n − k. This property halves the computational work when k > n/2 because the calculator can replace k with n − k and compute the smaller product. Symmetry also explains why Pascal's triangle is mirror-symmetric along its central axis and why the maximum coefficient in any row occurs at the center (or centers) of that row.
Are there closed-form approximations for large n?
Yes. Stirling's approximation, n! ≈ sqrt(2πn) (n/e)^n, yields an asymptotic formula for binomial coefficients: C(2n,n) ≈ 4^n / sqrt(πn). Entropy-based bounds such as 2^{n H(k/n)} / sqrt(8n(k/n)(1 − k/n)) provide tighter estimates, where H is the binary entropy function. These approximations are useful in information theory, statistical mechanics, and the analysis of algorithms where exact values are unnecessary. However, they introduce relative errors on the order of 1/n, which is unacceptable for exact combinatorial enumeration. The calculator returns exact integers for all supported inputs.
How does this relate to the binomial theorem?
The binomial theorem states that (a + b)^n = sum_{k=0}^{n} C(n,k) a^{n − k} b^k. The coefficients C(n,k) are therefore the weights that distribute the nth power across the terms of the expansion. When a = b = 1, the theorem reduces to sum_{k=0}^{n} C(n,k) = 2^n. When a = 1 and b = −1, the alternating sum equals 0 for n > 0. These identities are central to generating-function proofs in combinatorics. The calculator provides the individual coefficients that would otherwise require expanding the full polynomial, saving time in algebra and calculus coursework.
Can I use this calculator for multinomial coefficients?
Not directly. Multinomial coefficients generalize binomial coefficients to partitions of n into more than two groups: n! / (n_1! n_2! ... n_m!). The binomial coefficient is the special case m = 2. While the underlying factorial mathematics are related, the input schema, validation rules, and combinatorial interpretation differ. Users seeking multinomial coefficients should compute them as a product of successive binomial coefficients: n! / (n_1! n_2! ... n_m!) = C(n,n_1) × C(n − n_1,n_2) × ... × C(n_m,n_m). The calculator can be used iteratively for this purpose, but a dedicated multinomial tool would be more efficient.

References& sources.

  1. [1]NIST Digital Library of Mathematical Functions (2024). "Combinatorial Analysis." https://dlmf.nist.gov/26.3
  2. [2]Graham, R.L., Knuth, D.E., Patashnik, O. (1994). Concrete Mathematics: A Foundation for Computer Science, 2nd ed. Addison-Wesley.
  3. [3]Knuth, D.E. (1997). The Art of Computer Programming, Vol. 1: Fundamental Algorithms, 3rd ed. Addison-Wesley.
  4. [4]Feller, W. (1968). An Introduction to Probability Theory and Its Applications, Vol. 1, 3rd ed. Wiley.
  5. [5]NIST SP 811 (2008). Guide for the Use of the International System of Units (SI). https://www.nist.gov/pml/special-publication-811

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 313 calculators remain free
  • No billing is enabled
Coming soon