Let $p$ be a prime number. Show that the number of solutions to $x^k \equiv 1 \pmod p$ is $gcd(k, p-1)$

I'm really not convinced by my own proof of this. Would appreciate a critique/reformulation using the ideas I already introduced.

First note that $a^k \equiv 1 \mod p \implies k\ |\ p -1$ by Fermat's Little Theorem, where $p$ is prime

So we have $d\ |\ k$. And that $d\ |\ k\implies d\ |\ p - 1$, so $d\ |\ gcd(k, p-1)$

Let $x = a^i$ where $a$ is a primitive root$\pmod p$

So $x^k = (a^i)^k = (a)^{ik}$. Note $ik\ |\ p - 1$ which occurs when i = $\frac{p-1}{k}, 2\cdot\frac{p-1}{k},...,gcd(k,p-1)\cdot$

So we have $gcd(k, p-1)$ solutions.


In your first line, $k=2p-2$ works but $k \nmid p-1.$ So without further restrictions on $k$, the line is wrong.

In the second line, $d$ is undefined. But perhaps that doesn't matter, since $d$ never appears again.

In the fourth line, it's not true that $ik \mid p-1$.

To fix the proof, throw everything away except the 3rd line, and then rewrite the 3rd line so that your terms are well-defined.