Shuffling $\{1,2,\dots,n\}$ into an index loop I am not sure if index loop is a proper name, but what I mean is that if you are at position $i$ of the array $A$ (1-based indexing), then your next position will be at $A[i]$, and your next-next position will be $A[A[i]]$, and so on. An index loop forms if you eventually visit all elements of the array and return to your starting point. WLOG, one always starts from index 1.
For example, let $A=\{1,2,3,4,5\}$. Then $A' = \{5,4,3,2,1\}$ won't work because one just jumps back and forth between the first and last elements. But $A'=\{5,4,1,3,2\}$ works.
So, what is the criterion of a successful shuffle? And how many ways of shuffling are there given an array of length $n$?
If this is a well-known and solved problem, kindly let me know.
 A: The index loop you concerned is called a 'cycle permutation' of length $n$.
Any permutation of a sequence can be represented by several cycle permutations.
You may find the wiki page useful: https://en.wikipedia.org/wiki/Cyclic_permutation.
The number of $n$-cycles is given by $(n-1)!$.
Or directly, you can consider what can '1' map to, say $i$ (with $(n-1)$ different choices), then what can $i$ map to (with now $(n-2)$ different choices), and multiply the number of choices together:
$$ \text{number of $n$-cycles} = (n-1)\times(n-2)\times\cdots\times 1 = (n-1)! $$
The followings are edition on the number of cycle permutations against all permutations according to the comments.
Obviously the number of all permutations is $N_p(n) = n!$.
The total number of cycle permutations, denoted as $N_c(n)$, can be formulated as:
\begin{equation}
    N_c(n) = \sum_{k = 1}^{n}\binom{n}{k}(k - 1)! = \sum_{k = 1}^{n}\frac{n!}{k(n - k)!}
\end{equation}
Notice that from the Chebyshev's inequality we have
\begin{equation}
    \begin{aligned}
        N_c(n) & = n!\sum_{k = 1}^{n}\frac{1}{k(n - k)!} = n!\sum_{k = 1}^{n}\frac{1}{k}\cdot\frac{1}{(n - k)!} \\
        & \le n!\cdot\frac{1}{n}\left(\sum_{k = 1}^{n}{\frac{1}{k}}\right) \left(\sum_{k = 1}^{n}{\frac{1}{(n - k)!}}\right) \\
        & = (n - 1)!\left(\sum_{k = 1}^{n}{\frac{1}{k}}\right)\sum_{k = 0}^{n - 1}{\frac{1}{k!}} \\
    \end{aligned}
\end{equation}
Obviously the series $\sum_{k = 0}^{+\infty}{(k!)^{-1}}$ converges so $\sum_{k = 0}^{n}{(k!)^{-1}}$ is bounded above by a fixed number $M$.
Now we can get to the ratio of $N_c(n)$ in $N_p(n)$:
\begin{equation}
    \begin{aligned}
        \varepsilon_n & = \frac{N_c(n)}{N_p(n)} \\
        & \le \frac{(n - 1)!\left(\sum_{k = 1}^{n}{\frac{1}{k}}\right)\sum_{k = 0}^{n - 1}{\frac{1}{k!}}}{n!} \\
        & \le \frac{M}{n}(\ln{n} + 1)  \\
    \end{aligned}
\end{equation}
Clearly, $\varepsilon_n \to 0$ as $n \to \infty$.
Therefore it can be concluded that the number of cycle permutations are far smaller than the number of all permutations, which is identical with our intuition.
