combinations

Calculate the number combinations in a population size n, whilst selecting k items

int combinations(int n, int k);

will return the total number of unique combinations in a population size n, whilst selecting k items. There is no custom return type, the function always returns an integer.

combinations(4, 2); //6
combinations(5, 3); //10
combinations(3, 2); //3

Last updated