I kinda have a solution in mind for this and it goes like so:

there are a total of 10! permutations (10 digits total), the first 9! (from 1 - 9!) solutions contain 0 as the first digit, second 9! (9! - 9!*2) contain 1 as the first and so on until 9!*10 which contains 9 as the first digit, when u find the range of the first digit you know you will have now 9! options, first 9! will contain 0 (or 1 if you have 0 as the first digit), second 9! (9!-9!*2) will contain 1(or 0 if you have 1 as the first digit) and you reapeat this procces until 2! = 2 (then you will have only one option), how do you bring this idea into (fast running if possible) code?

thanks in advance

Edit: i meant 8! in the second digit, idea is to decrement the factorial every digit you go