Power of a cycle 
If I have the cycle $$\begin{pmatrix}1 & 10 & 5 & 7 & 2 & 9 &
 12\end{pmatrix}$$ what is $$\begin{pmatrix}1 & 10 & 5 & 7 & 2 & 9 &
12\end{pmatrix}^5$$

I know that a cycle of prime length raised to any power is again a cycle and I've wondered if there is any algorithmic way of calculating these powers.

I try to give you an Hint:
If $\sigma$ is your cycle, you have that $\sigma(1)=10$ and 
$$\sigma^2(1)= \sigma (\sigma (1))=\sigma(10)=5$$
You can easely check that $\sigma^5(1)=9$.
Note that $9$ is  the fifth number in your cycle after 1.
Can you generalize this example to obtain you fifth power of $\sigma$?
