TITLE: Show $a^p \equiv b^p \mod p^2$
QUESTION [10 upvotes]: I am looking for a hint on this problem:

Suppose $a,b\in\mathbb{N}$ such that $\gcd\{ab,p\}=1$ for a prime $p$. Show that if $a^p\equiv b^p \pmod p$, then we have: $$a^p \equiv b^p \pmod {p^2}.$$

I have noted that $a,b$ are necessarily coprime to $p$ already, and Fermat's little theorem ($x^p\equiv x \pmod p$), but I do not see how I should apply it in this case if at all.
Any hints are appreciated!

REPLY [4 votes]: You could generalize this further. Here is one of the Lifting the Exponent Lemmas (LTE):

Define $\upsilon_p(a)$ to be the exponent of the largest prime power of $p$ that divides $a$.
If $a,b\in\mathbb Z$, $n\in\mathbb Z^+$, $a\equiv b\not\equiv 0\pmod{p}$, then $$\upsilon_p\left(a^n-b^n\right)=\upsilon_p(a-b)+\upsilon_p(n)$$

In your case, by Fermat's Little theorem $a^p\equiv b^p\not\equiv 0\pmod{p}\iff a\equiv b\not\equiv 0\pmod{p}$, therefore $$\upsilon_p\left(a^p-b^p\right)=\upsilon_p(a-b)+\upsilon_p(p)=\upsilon_p(a-b)+1$$
Therefore $p^2\mid a^p-b^p$.