mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
895 B
895 B
Function permutations
Compute the number of ways of obtaining an ordered subset of k elements
from a set of n elements.
Permutations only takes integer arguments. The following condition must be enforced: k <= n.
Syntax
math.permutations(n)
math.permutations(n, k)
Parameters
| Parameter | Type | Description |
|---|---|---|
n |
Number | BigNumber | The number of objects in total |
k |
Number | BigNumber | The number of objects in the subset |
Returns
| Type | Description |
|---|---|
| Number | BigNumber | The number of permutations |
Examples
math.permutations(5); // 120
math.permutations(5, 3); // 60