This content is licensed under Creative Commons Attribution/Share-Alike License 3.0 (Unported). That means you may freely redistribute or modify this content under the same license conditions and must attribute the original author by placing a hyperlink from your site to this work https://planetcalc.com/3757/. Also, please do not modify any references to the original work (if any) contained in this content.
This calculator which generates possible combinations of m elements from the set of element with size n. Number of possible combinations, as shown in Combinatorics. Combinations, arrangements and permutations is
The description of generator algorithm is below the calculator
Combinations are generated in lexicographical order. Algorithms uses indexes of the elements of set.
Here is how it works on example:
Suppose we have a set of 5 elements with indexes 1 2 3 4 5 (starting from 1) and we need to generate all combination size m = 3.
First we initialize first combination size m - indexes in ascending order
1 2 3
We start from checking the last element (i.e. i = 3). If its value less than n - m + i, it is incremented by 1.
1 2 4
Again we check last element, and, since it is still less than n - m + i, it is incremented by 1.
1 2 5
Now it has the maximum allowed value: n - m + i = 5 - 3 + 3 = 5, so we move on to the previous element (i = 2).
If its value less than n - m + i, it is incremented by 1, and all following elements are set to value of their previous neighbor plus 1
1 (2+1)3 (3+1)4 = 1 3 4
Then we again start from the last element i = 3
1 3 5
Back to i = 2
1 4 5
Now it finally equals n - m + i = 5 - 3 + 2 = 4, so we can move to first element (i = 1)
(1+1)2 (2+1)3 (3+1)4 = 2 3 4
2 3 5
2 4 5
3 4 5 - last combination since all values are set to the maximum possible values of n - m + i.
- • Combinatorics. Combinations, arrangements and permutations
- • Combinatorics. Permutation generator from N to M with repetitions.
- • Combinatorics. Permutation generator from N to M without repetitions.
- • Generator of combinations which satisfy a condition
- • Making up words out of the syllables
- • combinatorics section ( 14 calculators )