I am generating numbers as follows:
Let the first digit range from 1 to 2 inclusive. Let the second digit range from 1 to 3 inclusive. Let the last digit range from 1 to 2 inclusive.
I am then generating all the possible numbers by cycling the last digit, then the middle, then the first to get this:
1 1 1
1 1 2
1 2 1
1 2 2
1 3 1
1 3 2
2 1 1
2 1 2
and so on.
How would you find the Nth number in the list generated using this method. For example, querying for the 2nd number would return 111, while querying for the 3rd would return 121.