### 12.2.10 Signature of a permutation

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 p, a permutation.
- signature(p) returns the signature of the permutation p.

#### Example

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

−1 |  |  |  |  |  |  |  |  |  |