Working with numbers? See sign (arithmetic)

Returns the sign or parity of a permutation. It can be defined as the parity of pairs of elements x comma y such that x less than y and sigma left parenthesis x right parenthesis greater than sigma left parenthesis y right parenthesis. Thus, the sign is +1 is sigma is even or -1 if it is odd. Alternatively, the sign of a permutation can be defined from its decomposition into the product of transpositions as left parenthesis negative 1 right parenthesis to the power of m, where m is the number of transpositions in the decomposition (although such decomposition is not unique, the parity is an invariant).


Given a permutation, returns its sign.