How do I calculate all possible permutations of an array of length n? If I draw on a paper, I can do myself permutations of 3 or 4 length arrays. However, I want an algorithm to calculate all possible permutation. And calculate it as fast as possible. Do you know how to do it? I would appreciate any help. Thanks.