*** Permutations
[1.3.1]
А. No repetition
n = 3 { 1 2 3 } - ordered set of n elements.
123 132 213 231 312 321
Total number: n!
[permute.cpp]
Б. With repetition n
= 4 { 1 1 2 3 } - ordered multiset of n elements
1123 1132 1213 1231 1312 1321
2113 2131 2311 3112 3121 3211
Total number: n!/(s1!s2!...sk!),
where si! is the number of i-th different element in the
multiset,
For the example: 4!/(2!1!1!) = 12
*** k-permutations of n (Variations) [1.3.2] - ordered k-element list of n elements
A. No repetition n
= 3 { 1 2 3 }, k = 2
12 13 21 23 31 32
Total number n!/(n - k)!
For the example: 3!/1 = 6
B. With repetitions n
= 3 { 1 2 3 }, k = 2
11 12 13 21 22 23 31
32 33
Total number nk
For the example: 32 = 9
[variate.cpp]
*** Combinations
[1.3.3] - k-element subset of n elements
(unordered)
A. No repetition n
= 5 { 1 2 3 4 5 }, k = 2
12 13 14 15 23 24 25
34 35 45
Total number n!/((n - k)!k!)
For the example: 5!/(3!2!) = 10
[comb.cpp]
B. With repetition n
= 5 { 1 2 3 4 5 }, k = 2
11 12 13 14 15 22 23
24 25 33 34 35 44 45 55
Total number (n + k - 1)! / ((n - 1)! k!)
For the example: 6!/(4!2!) = 15