Algorithm for computing permutations.