Project Euler problem number #24 deals with permutations in lexicographical order. A non-brute force approach involves a mixed base number system based on factorials.
This problem is one of those that I solved using pen and paper after some research. I used the following Wikipedia pages:
- Permutation where I learned that there is a connection between the lexicographical order of a permutation and
- the factorial number system representation of that particular number
Finally, you will need to remember that the Wikipedia articles both counts 0,1,2,… while the Euler problem counts 1,2,3,…. That is, adjust your offsets properly
Factorial Number System
Base 10 number :