For a permutation of ordered distinct values, its Lehmer code has entries . Its zero-based lexicographic order rank is . Each entry chooses among the still unused values; the factorial weights count all completions with a smaller choice at the first differing position.
New to topics? Read the docs here!