The permutations of $1,2,3,4,5$ are lexicographically ordered. $X$th permutation is $25314$. Find $X$.
I am getting $1*4! + 3*3! + 1*2! + 1=45$. Is it correct?
Reasoning: There are $1*4!$ numbers of the form of $1X_1X_2X_3X_4$. Similarly, there are $3*3!$ numbers of the form of $2YX_1X_2X_3$ where $Y \in \{1,3,4\}$. We continue the pattern this way to get the answer.
Your answer is correct.
There are $4!$ permutations which have a $1$ in the first position, all of which precede the first permutation which begins with a $2$.
Each permutation which begins with $21$, $23$, or $24$ precedes the first permutation which begins with $25$. Since there are $3!$ permutations which begin with $21$, $3!$ permutations which begin with $23$, and $3!$ permutations which begin with $24$, there are $3 \cdot 3!$ permutations which begin with $2$ that precede the first permutation which begins with $25$.
Hence, there are $4! + 3 \cdot 3!$ permutations which precede the first permutation which begins with $25$.
Of the permutations which begin with $25$, those that begin with $251$ precede the first permutation which begins with $253$. Since there are $2!$ permutations which begin with $251$, there are $4! + 3 \cdot 3! + 1 \cdot 2!$ permutations which precede the first permutation which begins with $253$.
Of the permutations that begin with $253$, $25314$ is the first. Hence, the position of the permutation $25314$ if the permutations of $1, 2, 3, 4, 5$ are listed in increasing order is indeed $$4! + 3 \cdot 3! + 1 \cdot 2! + 1 = 45$$