$(a+pk)^{p-1}≡1+ph−pka^{p−2} \mod{p^2}$, for some $h∈\mathbb{Z}$; if $k≢ah \mod{p}$, then $a+pk$ is a primitive root mod $p^2$.

Started an introductory number theory class and totally stuck on some homework after hours of effort. Feel like I'm so close but can't do the final bit to solve it and starting to wonder if my approach is wrong.

Question: $$p$$ is an odd prime, $$a$$ is a primitive root mod $$p$$, and $$k$$ is an integer.

I'm trying to show that $$(a+pk)^{p-1}≡1+ph−pka^{p−2} \mod{p^2}$$, for some $$h∈\mathbb{Z}$$; then that if $$k≢ah \mod{p}$$, then $$a+pk$$ is a primitive root mod $$p^2$$.

What I've done: I've made some progress by showing that the order of $$(a+pk) \mod{p^2}$$ is either $$p-1$$ or $$p(p-1)$$. After that, the first part of the problem is straightforward if the order is $$p-1$$ ($$h=ka^{p−2}$$).

But, if the order is $$p(p-1)$$, I can use the binomial to get to $$(a+pk)^{p-1}≡a^{p−1} - pka^{p-2} \mod{p^2}$$. Getting close to what I have to show but not sure where to go from there.

For the second part of the problem, it's a similar issue. I can get to $$(a+pk)^{p-1}≢ 1+ph-pha^{p-1} \mod{p^2}$$.

Then of course if $$a^{p-1} ≡ 1\mod{p^2}$$, then $$(a+pk)^{p-1}≢ 1 \mod{p^2}$$, and $$(a+pk)$$ is a primitive root since it can only have order of $$p-1$$ or $$p(p-1)$$.

But if the order of $$a$$ is $$p(p-1)$$ instead, I don't know where to go from there.

• Does this answer your question? If $r$ is a primitive root mod $p$ and $(r+tp)^{p-1} \not \equiv 1 \pmod{p^2}$, then $r+tp$ is a primitive root mod $p^k$ - found using an Approach0 search. Note $k\not\equiv ah\pmod{p}$ means ... Commented Jan 22, 2023 at 0:27
• (cont.) $(a+pk)^{p-1}\equiv 1+ph-pka^{p-2}\not\equiv 1\pmod{p^2}$, so the proposed duplicate question basically deals with the same problem you're asking about. Also, last but not least, welcome to Math SE. Commented Jan 22, 2023 at 0:29
• For the first part: Since $a$ is a primitive root mod $p$, we get that $a^{p - 1} - 1 = ph$ for some $h \in \Bbb Z$. This is an equation in $\Bbb Z$. This continues to hold mod $p^2$ as well. Commented Jan 22, 2023 at 0:29
• @JohnOmielan thank you very much for the welcome :) I already managed to get the step in the duplicate question, what I can't understand is how you got to the step in your comment. Isn't that contingent on $a^{p-1} ≡ 1\mod{p^2}$? But the order of $a$ could be $p(p-1)$ instead. Commented Jan 22, 2023 at 0:45
• Note $1+ph-pka^{p-2}\equiv 1\pmod{p^2}$ is equivalent to $ph\equiv pka^{p-2}\pmod{p^2}\iff h\equiv ka^{p-2}\pmod{p}\iff ha\equiv ka^{p-1}\equiv k\pmod{p}$. In other words, to get $k \not\equiv ah\pmod{p}$ to mean that $1+ph-pka^{p-2}\not\equiv 1\pmod{p^2}$, it's only required that $a^{p-1}\pmod{p}$, which is true for any $a \not\equiv 0\pmod{p}$ by Fermat's little theorem, not necessarily just for a primitive root $a$. Commented Jan 22, 2023 at 0:51