Let $p$ be prime and $f, g \in (\mathbb{Z}/p\mathbb{Z})[X]$. Prove:
$$(\forall x \in \mathbb{Z}/p\mathbb{Z}: f(x) = g(x) ) \iff f - g \in (X^p - X)$$
My approach:
First $\implies$. As $p$ is prime, $\mathbb{Z}/p\mathbb{Z}$ is a field, so it has no zero divisors, and $f - g$ is zero for all $x \in \mathbb{Z}/p\mathbb{Z}$. So $(f - g)(X) = Q(X)\Pi_{i = 0}^{p - 1}(X - i)$. I think we might get a factor $X^p - X$ out of the product, but I can't manage that.
I did manage to do the reverse implication if that matters:
$\Leftarrow: $ Suppose $(f - g)(X) = (X^p - X)Q(X)$ for some $Q \in (\mathbb{Z}/p\mathbb{Z})[X]$. Then for any $x \in \mathbb{Z}/p\mathbb{Z}$ we have that $x^p = x$ (Fermat's little theorem), so $(f - g)(x) = 0$ for all $x \in \mathbb{Z}/p\mathbb{Z}$, so $f(x) = g(x)$ for all $x \in \mathbb{Z}/p\mathbb{Z}$.
Any hints?
Nice work! It seems like you only need to show $$ \prod_{i=1}^{p-1}(X-i)=X^p-X. $$ Instead of expanding the product, we will simply factor the right hand side. From your second implication, you know that $X^p-X$ has $p$ roots in $\mathbb{Z}/p\mathbb{Z}$ by Fermat's little theorem. But you are working over a field, so if $\alpha$ is a root of $h(X)$, then you can divide and write $h(X)=q(X)(x-\alpha)$.
Moreover, if you know all the roots of a polynomial, you can continue the division to write $h$ in terms of linear factors. What does this mean for the factorization of $X^p-X$?