Prove that exactly $\varphi (d)$ residues have order $d$ modulo $p$ for all $d \mid \varphi(p)$ where $p$ is prime.
I was wondering if there was a way to solve this using number theory and not group theory. Here was the start of my attempt:
Let $g$ be a primitive root modulo $p$, so that $\text{ord}_p(g) = \varphi(p) = p-1$ and $\{g,g^2,\ldots,g^{p-1}\}$ is the complete residue system modulo $p$. It suffices to find the number of $m$ such that $\text{ord}_p(g^m) = d$.
We know that $g^{dm} = g^{(p-1) \cdot \frac{dm}{p-1}}$.
How do we continue from here?