# 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 • There are n! permutations of a list of n distinct elements.
• Repeated elements are treated as identical. »
• The object list need not have head List.
• Permutations[list] is effectively equivalent to Permutations[list,{Length[list]}].
• Permutations[list,{nmin,nmax}] gives permutations of between nmin and nmax elements.

# 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(3)

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 n!/(n-r)!:

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

Introduced in 1988
(1.0)
|
Updated in 2007
(6.0)