# Signature of a permutation: signature

### 5.9.10 Signature of a permutation: signature

Every permutation can be decomposed into a product of transpositions (cycles with only two elements). The number of transpositions is not unique, but for any permutation the number will be either odd or even. The signature of a permutation is equal to:

- 1 if the permutation is equal to an even product of transpositions,
- -1 if the permutation is equal to an odd product of transpositions.

The signature of a cycle of size k is: (−1)k+1.

The signature command computes the signature of a permutation.

- signature takes one argument:
  p, a permutation.
- signature(p) returns the signature of the permutation p.

#### Example.

Input:

signature([3,4,5,2,0,1])

Output:

−1