Permutation Sign Calculator

Enter a permutation of 1..n to find its sign and parity.

How it is calculated

The tool counts inversions: pairs of positions i < j where the value at i is larger than the value at j. The sign is (−1)inversions, so an even count gives +1 (even permutation) and an odd count gives −1 (odd permutation). Enter the numbers separated by spaces or commas, with no brackets. The list must be exactly a rearrangement of 1..n: every number from 1 to n once. A repeated number, a gap (1 2 4), a 0, a single entry such as 5, or brackets such as (2,1,3) return no result. The count is a plain double loop, so there is no rounding, and the rule does not depend on country or year.

Worked example

Permutation 3 1 4 2 5. Check each pair where an earlier number is larger than a later one: (3,1), (3,2) and (4,2). That is 3 inversions; 5 is in its place and creates none. Three is odd, so the sign is (−1)3 = −1. The tool shows −1 (odd), 3 inversions, parity odd.

Try this example →

Common mistakes

  • Typing the cycle notation or brackets, (2,1,3) or [2 1 3]; only bare numbers separated by spaces or commas are read.
  • Entering a list that is not a rearrangement of 1..n, for example 1 2 4 or 2 3 4, or one with a repeat; the tool returns nothing rather than guessing.
  • Starting from 0, as many programming languages index; the numbers must run 1 to n.
  • Counting only neighbouring pairs or only the numbers out of place: an inversion is any pair, however far apart, so 3 1 2 has two inversions (3 before 1, 3 before 2).
  • Confusing the sign with the number of inversions: 10 inversions or 4 inversions both give +1; only the odd or even parity matters.

About this calculator

The sign (or parity) of a permutation of 1..n tells you whether it can be built from an even or odd number of pairwise swaps (transpositions) of the identity order. This calculator counts inversions — pairs of positions where a larger number appears before a smaller one — and reports even inversions as sign +1, odd as sign −1.

For example, the permutation (2,1,3) has exactly one inversion (2 before 1), so it's odd with sign −1, while (2,3,1) has two inversions and is even with sign +1. This is exactly the quantity that appears in the Leibniz formula for a matrix determinant, where each term in the sum is weighted by the sign of the permutation defining that term.

Linear algebra and combinatorics students use it to check determinant expansions by hand, and it comes up in group theory when classifying elements of the symmetric group S_n as belonging to the alternating group (even permutations only).

Was this helpful?

You can pick up to 3 reactions.

Be the first to comment.

Popular calculators

All Calculators