How many permutations can be obtained in the output (in the same order) using a stack assuming that the input is the sequence $(1, 2, 3, 4, 5,\dots, n)$ in that order?
Example If $n=5$, then outputs
- $3,4,5,2,1$
- $1,2,3,4,5$
- $5,4,3,2,1$ etc.
are possible, and outputs
- $3,4,5,1,2$
- $1,5,2,3,4$
- $5,4,3,1,2$ etc.
are impossible.