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

The factorial
number system is a mixed base representation of a number. I have
created a small JavaScript converter that converts base-10 numbers
into the corresponding factorial base number. It works with standard
JavaScript integers and is therefore only able to convert numbers less
than 2^{31} = 2147483648. In order to represent numbers larger
than 9 I extend the numbers with A, B, C... hex-style!

Base 10 number : Convert

Converted numbers:

Base 10 | Factorial |

You can use the comment system below or send my an email mic.jacobsen@gmail.com

comments powered by Disqus