Following are common definition of Binomial Coefficients.
- A binomial coefficient C(n, k) can be defined as the coefficient of X^k in the expansion of (1 + X)^n.
- A binomial coefficient C(n, k) also gives the number of ways, disregarding order, that k objects can be chosen from among n objects; more formally, the number of k-element subsets (or k-combinations) of an n-element set.
Given two numbers n and r, find value of nCr
Input : n = 5, r = 2 Output : 30 The value of 5C2 is 10 Input : n = 3, r = 1 Output : 3
The idea is simply based on below formula.
nCr = (n!) / (r! * (n-r)!)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Binomial Coefficient | DP-9
- Space and time efficient Binomial Coefficient
- Compute nCr % p | Set 1 (Introduction and Dynamic Programming Solution)
- Program to find LCM of two numbers
- Program for Decimal to Binary Conversion
- Count ways to distribute m items among n people
- Number of handshakes such that a person shakes hands only once
- Count pairs with Bitwise AND as ODD number
- Number of ways to reach Nth floor by taking at-most K leaps
- Count unique subsequences of length K