$2(n-1)! \equiv -1 \mod n+2 \iff n+2$ is a prime

Problem: Show that $$2(n-1)! \equiv -1 \mod n+2 \iff n+2$$ is a prime.

I know that Wilson's theorem states that $$(n-1)! \equiv -1 \mod p$$ for $$p$$ a prime, so that is the important thing to know with these type of problems.

I know that $$-1 \equiv n+1 \mod n+2$$ , and that if $$n+2$$ is prime, then $$(n+1)! = -1 \mod n+2$$. So this is all I have for now, any hints appreciated.

• Well, what is $(n+1)\times n\pmod {n+2}$? – lulu Apr 19 at 20:59
• @lulu $(-n) \mod n+2$ – IntegrateThis Apr 19 at 20:59
• Yes, and what is $n\pmod {n+2}$? – lulu Apr 19 at 21:00
• @lulu -2 I believe. – IntegrateThis Apr 19 at 21:00
• Yes, and what is $-1\times -2$? – lulu Apr 19 at 21:00

As per the comments since I know that $$2 (n-1)! \equiv (-1)(-2)(n-1)! \equiv (n)(n+1)(n-1)! \equiv (n+1)! \equiv -1 \mod (n+2)$$, then $$n+2$$ is prime.
• Just to be clear: Wilson's Theorem plus the algebraic manipulation you provide just show one direction. Specifically: they show that $n+2$ prime $\implies 2(n-1)!\equiv -1 \pmod {n+2}$. You need to show the converse as well. However, that's pretty easy (Hint: if $n+2$ is composite then it has a non-trivial factor $<n-1$, at least for $n≥4$). – lulu Apr 19 at 21:27