Project Euler Problem 720
Consider all permutations of 1, 2, ldots N, listed in lexicographic order.
Solution
Answer: 688081048
Using the recursive construction encoded in the verified solution logic, we compute the lexicographic rank of the first unpredictable permutation for $N=2^{25}$ modulo $1,000,000,007$.
The implementation reproduces the supplied checks:
- $S(4)=3$
- $S(8)=2295$
- $S(32)\equiv 641839205 \pmod{1,000,000,007}$
and then evaluates $S(2^{25})$.
Answer: 688081048