Let $[q] = \{0,\dots,q-1\}$, $p < q$.
Consider the function $\mathbf{p}: [q] \rightarrow [q]$ which sends $x \mapsto p·x\operatorname{mod}q$, i.e. the multiplication by $p$ modulo $q$ on $[q]$.
One finds that when $p$ and $q$ are coprime, $\mathbf{p}$ is a permutation of $[q]$ with $\mathbf{p}(0) = 0$.
Each such permutation – depending solely on $p$ and $q$ – has a specific cycle spectrum: $n_m$ cycles of length $m$.
How do I calculate the possible cycle lengths $m$ and their corresponding numbers $n_m$ just by looking at $p$ and $q$?


