Help me to program on with an input n, returns a list of all permutations of the numbers 1, 2, ..., n. Use the fact that all permutations of 1, 2,..., n can be obtained from all the permutations of 1, 2, ..., n-1 by inserting n in all possible places.

o this end, create a flat array having a size of n! * n. The array is just large enough to hold all permutations of size n, written contiguously into the array. For example, for n equals 3, the finished array could look like the following.

1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1 or

3, 2, 1, 2, 3, 1, 2, 1, 3, 3, 1, 2, 1, 3, 2, 1, 2, 3

Please help me