This question already has an answer here:
- Mathematical Combination 27 answers
Given two nonnegative integers
n,k such that
0 <= k <= n, return the binomial coefficient
c(n,k) := (n!) / (k! * (n-k)!)
Most languages will probably have a built in function.
c(n,0) = c(n,n) = 1 for all n c(n,1) = c(n,n-1) = n for all n c(5,3) = 10 c(13,5) = 1287