Help with proof of showing idempotents in set of Integers Modulo a prime power are $0$ and $1$

I was reading online for a project I’m currently doing and came across the following claim and proof. The statement would be useful to me, and although I’ve spent a long time looking at it there’s still a few steps that I just don’t follow and I was hoping someone could help me.

Claim: If $p$ is a prime number and $k$ a positive integer then the only idempotent elements in $\mathbb{Z}$/$p^k\mathbb{Z}$ are $0$ and $1$.

Proof:

An element, $x$, of $\mathbb{Z}$/$n\mathbb{Z}$ is idempotent if it is a solution to the congruence $x^2\equiv x \pmod {p^k}$. Clearly $x=0$ and $x=1$ are solutions to this congruence.

Say that $x\neq0$. Write $x=p^rs$ where $0\leq r<k$ and $\gcd(p,s)=1$.Then $s(p^rs-1)\equiv 0\pmod {p^{k-r}}$ which implies that $p^rs \equiv 1\pmod {p^{k-r}}$.

Hence $r$ must equal $0$ and $x=s\equiv 1\pmod {p^k}$.∎

Choosing $x\neq0$ and showing it to be equal to $1$ makes sense. However I don’t follow the next few congruences, why are they true? Since $\gcd(p,s)=1$, doesn’t this tell us that ${p^{k-r}}$ can’t divide $s$? In turn implying from the first congruence that ${p^{k-r}}$ divides $p^{r}s-1$. I don’t see why this is true? As for the following steps, I can see why $r$ must equal $0$, but unfortunately not the rest.

Sorry for the long post, any help is greatly appreciated.

Solutions Collecting From Web of "Help with proof of showing idempotents in set of Integers Modulo a prime power are $0$ and $1$"

The ring $\mathbb{Z}/p^k \mathbb{Z}$ is a local ring: it has a unique maximal ideal, the set of all multiples of $p$. (The ideals in the quotient ring $\mathbb{Z}/p^k \mathbb{Z}$ are precisely the ideals of $\mathbb{Z}$ containing $p^k$. Since $\mathbb{Z}$ is a PID, the result comes down to the fact that the only prime dividing $p^k$ is $p$.)

An element $e$ of a commutative ring is an idempotent if $e^2 = e$.

Here are some very easy facts about idempotents:

1) If $e$ is an idempotent, so is $1-e$: $(1-e)(1-e) = 1 – 2e + e^2 = 1-2e + e = 1-e$.
2) If an idempotent $e$ is a unit, then $e = 1$: multiply $e^2 = e$ by $e^{-1}$.
3) One says that an idempotent $e$ is nontrivial if neither $e$ nor $1-e$ is $0$. It follows from 2) that neither $e$ nor $1-e$ is a unit.

Proposition: A local ring has no nontrivial idempotents.

Proof: Let $\mathfrak{m}$ be the unique maximal ideal of $R$. If $e$ is a nontrivial idempotent, then by 3) above $e,1-e \in \mathfrak{m}$, hence $e + (1-e) = 1 \in \mathfrak{m}$, contradiction.

The key theorem that would help you is this.

Theorem. Let $b,c,d\in \mathbb{Z}$ with $d\neq 0$. Then

$$ad\equiv bd \pmod{c}$$

if and only if

$$a \equiv b \pmod{\frac{c}{\gcd(d,c)}}$$

Proof. Let $\alpha=\gcd(d,c)$, and set $c=c’\alpha$, with $\gcd(\alpha,c’)=1$. Similarly, set $d=d’\alpha$, with $\gcd(\alpha,d’)=1$. Also, $\gcd(c’,d’)=1$, by maximality of gcd. Now, suppose $ad\equiv bd \pmod{c}$. Then $c|(ad-bd)$. Translating, we get $c’\alpha | \alpha ad'(a-b)$. Cancel the $\alpha$ and we get $c’|d'(a-b)$. Since $\gcd(c’,d’)=1$, in fact $c’|(a-b)$. The other direction is simpler: suppose $c’|(a-b)$. Then $c’\alpha | \alpha ad'(a-b)$.