Permutations

Permutations[list]

generates a list of all possible permutations of the elements in list.

Permutations[list,n]

gives all permutations containing at most n elements.

Permutations[list,{n}]

gives all permutations containing exactly n elements.

Details

Examples

open allclose all

Basic Examples  (2)

Length-3 permutations of {a,b,c}:

Length-3 permutations of {a,b,c,d}:

Scope  (4)

Repeated elements are treated as identical:

Use any expressions as elements:

Get permutations of all lengths, shortest ones first:

Get even-length permutations, longest ones first:

Generalizations & Extensions  (1)

The list of elements can have any head:

Properties & Relations  (4)

The number of length-n permutations of a length-n list of distinct elements is n!:

The number of length-r permutations of a length-n list of distinct elements is FactorialPower[n,r]:

A permutation that leaves no element invariant is called a derangement:

The number of derangements of n distinct elements is Subfactorial[n]:

If the input list is in the order given by Sort, so are its length-r permutations:

Wolfram Research (1988), Permutations, Wolfram Language function, https://reference.wolfram.com/language/ref/Permutations.html (updated 2007).

Text

Wolfram Research (1988), Permutations, Wolfram Language function, https://reference.wolfram.com/language/ref/Permutations.html (updated 2007).

CMS

Wolfram Language. 1988. "Permutations." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/Permutations.html.

APA

Wolfram Language. (1988). Permutations. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Permutations.html

BibTeX

@misc{reference.wolfram_2024_permutations, author="Wolfram Research", title="{Permutations}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Permutations.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_permutations, organization={Wolfram Research}, title={Permutations}, year={2007}, url={https://reference.wolfram.com/language/ref/Permutations.html}, note=[Accessed: 22-December-2024 ]}