Perm1(m)
1 if m=n then output P[1..n]
2 else
3 for j←m to n do
4 P[j] ↔ P[m]
5 Perm1(m+1)
6 P[j] ↔P[m]
3
1 2 3
1 3 2
2 1 3
2 3 1
3 2 1
3 1 2