Show that if $p$ is prime, then the only solutions of the congruence $x^2 \equiv x \pmod p$ are those integers $x$ such that $x=0$ or $1 \pmod p$ 
Show that if p is prime, then the only solutions of the congruence $x^2\equiv x\pmod p$ are those integers $x$ such that $x\equiv \text{$0$ or $1$}\pmod p$.

I can't even begin to prove this question.
 A: $$x^2\equiv x\!\!\!\pmod p\,\overset{\rm def}\Rightarrow\, p\mid \color{#c00}x(\color{#0a0}{x-1})$$
Since $p$ is a prime,  Euclid's Lemma $\Rightarrow\,\color{#c00}{p\mid x}\ \ {\bf or}\ \ \color{#0a0}{p\mid x-1}$
$$\ \ \Rightarrow\ \color{#c00}{x\equiv 0}\ \ {\bf or}\ \ \color{#0a0}{x\equiv 1}\!\!\pmod p$$
Clearly both are roots of $\,x^2-x= x(x-1),\,$ hence they are the complete set of roots.
Remark $ $  The final "root checking" step is needed to rule out the possibility of extraneous roots due to the use of unidirectional $(\Rightarrow)$ inferences above. In fact all arrows hold bidirectionally, i.e. they are equivalences $(\!\!\iff\!\!),\,$ so we could eliminate the final checking step by using bidirectional inferences everywhere (see here for more on such).
A: As lulu mentioned in the comments, integers $\operatorname{mod} p$ form a field, denoted $\mathbb{F}_p$. In any field (in fact, in any integral domain), a polynomial of degree $n$ has at most $n$ roots. $x=0$ and $x=1$ are certainly roots of $x^2-x$, so there cannot be any other roots. Now, an integer $x$ is a solution to $x^2 \equiv x \pmod p$ iff $\bar x^2 - \bar x = \bar 0$ in the field $\mathbb{F}_p$ (here, $\bar x$ denotes the image of $x$ under the modulo $p$ projection map $\mathbb{Z} \rightarrow \mathbb{F}_p$).
