One way to generate the permutations is by using the factorial base (not to be confused with the Lehmer code).
Here is a detailed example showing how to compute a(2982).
We have i = 2982 = (4, 0, 4, 1, 0, 0, 0) in the factorial base.
So the initial vector "0" is (1, 2, 3, 4, 5, 6, 7), using seven active digits.
The factorial base vector is reversed, giving (0, 0, 0, 1, 4, 0, 4).
The instructions are to read from the factorial base vector, producing rotations to the right by as many steps as the column says, in the following order:
Start on the right; on the vector "0", a rotation of 4 units is made
(0, 0, 0, 1, 4, 0, [4])
(1, 2, 3, 4, 5, 6, 7)
The result is:
(4, 5, 6, 7, 1, 2, 3)
The 3 is retained, one column is advanced.
Next a rotation of 0 units is made (the null rotation)
(0, 0, 0, 1, 4, [0], 4)
(4, 5, 6, 7, 1, 2, 3)
The result is:
(4, 5, 6, 7, 1, 2, 3)
The 2 is retained, one column is advanced.
Now a rotation of 4 units is made
(0, 0, 0, 1, [4], 0, 4)
(4, 5, 6, 7, 1, 2, 3)
The result is:
(5, 6, 7, 1, 4, 2, 3)
The 4 is retained, one column is advanced.
Now a rotation of 1 units is made
(0, 0, 0, [1], 4, 0, 4)
(5, 6, 7, 1, 4, 2, 3)
The result is:
(1, 5, 6, 7, 4, 2, 3)
The 7 is retained, one column is advanced.
Now 3 null rotations are made.
All remaining values are retained: 6, 5, and 1
Thus 2982 represents the permutation: (1, 5, 6, 7, 4, 2, 3)
Or a(2982) = 1567423.