The binomial coefficient C(n,m) is the coefficient of xm in the expansion of (1+x)n.

C(n,m) can also be given a combinatoric intrepretation as the total number of ways to pick m items from a set of n distinct items.
For example C(4,2) = 6. This can be seen by expanding (1+x)4 = 1 + 4 x + 6 x2 + 4 x3 + x4 and noting that the coefficient of the x2 term is 6. It can also be seen by considering the four-member set (abcd) and noting that there are 6 possible two-member subests: (ab), (ac), (ad), (bc), (bd), (cd).
Pascal's triangle is a classic representation of binomial coefficients.
| C(0,0) | |||||||
| C(1,0) | C(1,1) | ||||||
| C(2,0) | C(2,1) | C(2,2) | |||||
| C(3,0) | C(3,1) | C(3,2) | C(3,3) | ||||
The relation of an element in Pascal's triangle to its two parent elements is C(n+1,m) = C(n,m-1) + C(n,m). There are many other relationships among binomial coefficients. Among the most computationally useful is B(n,m+1) = (n-m)/(m+1) B(n,m), which can be used to generate all the binomial coefficients in a row of Pascal's triangle (i.e., all the coefficients for a given order polynomial) starting from an outer values B(n,0) = 1 = B(n,n). If you need a series of binomial coefficients, using a recursion will be more computationally efficient than calling this method for each one. The BinomialCoefficients(Int32) method provides a fast enumeration of all the binomial coefficients in a given row of Pascal's triangle.
Binomial coefficients are always integers, but we return the result as double because the value can exceed the capacity of an int or even a long for even quite moderate values of n and m.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | n is negative, or m lies outside [0,n]. |