Given an array of N elements representing the permutation atoms, is there an algorithm like that:
function getNthPermutation( $atoms, $permutation_index, $size )
$atoms is the array of elements,
$permutation_index is the index of the permutation and
$size is the size of the permutation.
$atoms = array( 'A', 'B', 'C' ); // getting third permutation of 2 elements $perm = getNthPermutation( $atoms, 3, 2 ); echo implode( ', ', $perm )."n";
Without computing every permutation until $permutation_index ?
I heard something about factoradic permutations, but every implementation i've found gives as result a permutation with the same size of V, which is not my case.