Combinations

Overview


Combinations are similar to permutations, but in this case, the ordering does not matter. That is, two sets with the same items are considered the same regardless of how they are ordered. Because of this equality, there will be fewer combinations of items than permutations.

The number of combinations of {% n %} things taken {% k %} at a time is written as
{% \binom{n}{k} %}


The formula for the number of combinations is given:
{% C(n, k) = \binom{n}{k} = \frac{n!}{k!(n-k)!} %}

API


The combinatorics library provides methods for doing combinatoric calculations.


let cn = await import('/lib/combinatorics/v1.0.0/combinatorics.mjs');
//items to be combined
let items = [1,2,3,4,5,6,7,8,9];

//get all combinations of 3 of the numbers
let combinations = cn.combinations(items, 3);
					
Try it!