I'm not sure if the title is the correct description. What I want to do is basically like this: For example, if I have a binary sequence of 3-bits, I can have the following permutations:
1 -> [0,0,0]
2 -> [0,0,1]
3 -> [0,1,0]
4 -> [0,1,1]
5 -> [1,0,0]
6 -> [1,0,1]
7 -> [1,1,0]
8 -> [1,1,1]
But instead of binary sequence, I have a decimal array of integers upper bounded by some value N. Each of the digits can go from 0 to N.
So something like this:
1 -> [0,0,0]
2 -> [0,0,1]
3 -> [0,0,2]
...
i -> [0,0,N]
i+1 -> [0,1,0]
...
...
Is there a closed-form solution to find the digits of any n-th permutation? Even a recursive solution? Or is iterative the only option?