:orphan:
# PetscDTPermIndex
Encode a permutation of n into an integer in [0, n!).  This inverts `PetscDTEnumPerm()`. 
## Input Parameters

- ***n -*** a non-negative integer (see note about limits below)
- ***perm -*** the permuted list of the integers [0, ..., n-1]



## Output Parameters

- ***k -*** an integer in [0, n!)
- ***isOdd -*** if not `NULL`, returns whether the permutation used an even or odd number of swaps.





## Note
Limited to `n` such that `n`! can be represented by `PetscInt`, which is 12 if `PetscInt` is a signed 32-bit integer and 20 if `PetscInt` is a signed 64-bit integer.


## See Also
 `PetscDTFactorial()`, `PetscDTFactorialInt()`, `PetscDTBinomial()`, `PetscDTBinomialInt()`, `PetscDTEnumPerm()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscdt.h.html#PetscDTPermIndex">include/petscdt.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscdt.h)


[Index of all DT routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
