Number.Permutations
NumberReturns the number of permutations for choosing k items from a set of n items, where order matters (P(n,k)).
Syntax
Number.Permutations(setSize as nullable number, permutationSize as nullable number) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
setSize | number | Yes | The total number of items in the set (n). Must be a non-negative integer. |
permutationSize | number | Yes | The number of items to arrange (k). Must be a non-negative integer <= setSize. |
Return Value
number — The number of ordered arrangements P(n,k) = n! / (n-k)!.
Remarks
Number.Permutations computes P(n, k) — the number of distinct ordered arrangements of permutationSize items drawn from a set of setSize items. Unlike Number.Combinations, order matters: selecting item A then B is a different outcome than B then A.
The formula is: P(n, k) = n! / (n − k)!
The relationship between permutations and combinations is: P(n, k) = C(n, k) × k!, because for each combination of k items, there are k! ways to arrange them. Number.Permutations(n, k) is always ≥ Number.Combinations(n, k) (equal only when k = 0 or k = 1).
Special cases: P(n, 0) = 1 (one way to arrange nothing), P(n, n) = n! (total orderings of the full set). When permutationSize > setSize, the result is 0 (impossible).
Use Number.Permutations when order is meaningful: race placements, password combinations, scheduling sequences, or any scenario where the same items in a different order count as a distinct outcome.
Examples
Example 2: How many ways can 3 runners finish 1st, 2nd, 3rd from 8 competitors?
Number.Permutations(8, 3)Result | |
|---|---|
| 1 | 336 |
Example 3: Compare permutations vs combinations — ratio equals k!
#table(
{"Measure", "Value"},
{
{"Combinations C(8,3)", Number.Combinations(8, 3)},
{"Permutations P(8,3)", Number.Permutations(8, 3)},
{"Ratio P/C = k! = 3!", Number.Permutations(8, 3) / Number.Combinations(8, 3)}
}
)Measure | Value | |
|---|---|---|
| 1 | Combinations C(8,3) | 56 |
| 2 | Permutations P(8,3) | 336 |
| 3 | Ratio P/C = k! = 3! | 6 |