Wilson's Theorem: (n-1)! is congruent to -1(mod n) implies that n is prime. I have researched Wilson's theorem several times over stack exchange. I would only like to prove one direction. This seems to be a good explanation: Prove that $(n-1)! \equiv -1 \pmod{n}$ iff $n$ is prime
However, on their explanation, the author states that $k|(n-1)!$ implies that $k$ is congruent to $1$(mod $n$). I don't see their jump in logic. I am looking for either an explanation or a reference to a theorem if possible. Any assistance is appreciated. Thank you

I am not sure how the answer in the linked post derives that
$$ k \equiv 1 \pmod n $$
Instead, here as an alternative way to complete the proof. As in the linked answer, we assume that we have an integer $k$ such that $k<n$ and $k \mid n$. We know that
$$ (n-1)! \equiv -1 \pmod n$$
and so since $k \mid n$
$$ (n-1)! \equiv -1 \pmod k$$
Since $k < n$, we have that
$$ (n-1)! \equiv 0 \pmod k $$
(provided of course that $n>1$)
This gives us that
$$ 0 \equiv -1 \pmod k$$
and so $k \mid 1$ as claimed in the linked answer.
