I came across a proof of Wilson's theorem as shown below.
I understand why the degree of $f(X)$ has to be strictly less than $p - 1$, and why there are $p - 1$ solutions to $f(a) \equiv 0$ (mod $p)$ in {$1,2,...p-1$}. However, it is not clear to me why, from these two statements, it can be concluded that all coefficients of $f(X)$ are divisible from $p$ [the highlighted statement]. I feel like it has something to do with the fact that $f(X)$ has (at most) $p-2$ terms i.e. there are $p - 2$ coefficients, and that reducing the coefficients mod $p$ will result in at least two coefficients being equal to each other. From there, it is clear to me how to conclude that $f(0) \equiv 0$ (mod $p$), and how this can be used to prove Wilson's theorem.
