mathjs/docs/reference/functions/permutations.md
2022-03-01 13:04:09 +01:00

56 lines
1.5 KiB
Markdown

---
layout: default
---
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
<h1 id="function-permutations">Function permutations <a href="#function-permutations" title="Permalink">#</a></h1>
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.
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.permutations(n)
math.permutations(n, k)
```
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`n` | number &#124; BigNumber | The number of objects in total
`k` | number &#124; BigNumber | The number of objects in the subset
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
number &#124; BigNumber | The number of permutations
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
Type | Description
---- | -----------
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
```js
math.permutations(5) // 120
math.permutations(5, 3) // 60
```
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
[combinations](combinations.html),
[combinationsWithRep](combinationsWithRep.html),
[factorial](factorial.html)