Calculates the number of permutations of k items selected from n items. If replacement is true, calculates n^k (with replacement). If false, calculates n! / (n - k)! (without replacement).
k
n
replacement
Total number of items (n ≥ 0)
Number of items to arrange (k ≥ 0)
Whether replacement is allowed (default: true)
The number of permutations
permutations(5, 2); // 25 (with replacement)permutations(5, 2, false); // 20 (no replacement) Copy
permutations(5, 2); // 25 (with replacement)permutations(5, 2, false); // 20 (no replacement)
Calculates the number of permutations of
k
items selected fromn
items. Ifreplacement
is true, calculates n^k (with replacement). If false, calculates n! / (n - k)! (without replacement).