Combine
Description
This function is used to calculate the number of k-combinations from a given set with n elements, denoted by:
Please note that a combination is different from a permutation in which the combination is a set of elements regardless of the internal order, while the internal order in a permutation is significant. For example, in the 3 elements of "a, b, c", "ab" and "ba" are considered the same combination but two different permutations.
Syntax
double Combine(int n, int k)
Parameters
n
- The number of elements in a given set. It must be a positive integer.
k
- The k-combinations. It must be a positive integer and k < n.
Return
Return the number of k-combinations from a given set with n elements
Example
combine(4, 2) = ; // returns 6 Combine(8, 2) = ; // returns 28
/math-94f63039206f9fe0864e20d9a753e6b0.png)