I recently came upon a strange pattern, and have absolutely no idea why it exists. I was hoping for an explanation.
Let there be three integers: $p$, $a$ and $n$; $p$ is any prime number, while $a$ and $n$ are numbers such that $1\leq a < p$ and $1 \leq n < p$
Let Set $S$ be $\{{an^1\pmod p, an^2\pmod p, \dots, an^{p-1}\pmod p\}}$. Why is it that the number of distinct numbers in Set $S$ is always a divisor of $p-1$?
An example : Let $p$ be 7, $a$ be $3$ and $n$ be $2$.
Therefore Set S would be : $\{{3 * 2^1\pmod7,\dots,3* 2^6\pmod7\}}$
which equals to: $6\pmod 7$, $5\pmod7$, $3\pmod 7$, $6\pmod7$, $5\pmod7$, $3\pmod7$.
There are 3 distinct numbers in this set. $6$, or $p-1$, is divisible by $3$.
This is true for any prime $p$. Why is the number of distinct numbers in Set $S$ always a divisor of $p-1$?
I realize this is a seemingly random pattern, but I need to understand it to complete my paper.