# If $p\equiv 3\pmod{4}$ is a prime, then $\frac{p-1}{2}! \equiv \pm1 \pmod p$

If $p\equiv 3\pmod{4}$ is a prime, then $\frac{p-1}{2}! \equiv \pm1 \pmod p$.

I don't know how to prove this statement.

$p=4m+3$, so $(2m+1)! \equiv \pm1\pmod p$

This is all I did.

• Do you know Wilson's theorem? – Daniel Fischer Oct 18 '15 at 12:42
• Shall I interpret that as "No, I'm new to the topic, I haven't yet heard of it"? – Daniel Fischer Oct 18 '15 at 12:45
• Related: Why does $(\frac{p-1}{2}!)^2 = (-1)^{\frac{p+1}{2}}$ mod $p$?; probably there are more similar duplicates – punctured dusk Oct 18 '15 at 12:47
• $p\text{ is prime}\iff (p-1)!+1\equiv0\pmod{p}$ – barak manos Oct 18 '15 at 12:59
• And you should most definitely change $(p-1/2)!$ to $((p-1)/2)!$ – barak manos Oct 18 '15 at 13:05

$\left( \frac{p-1}{2}! \right)^2 = \prod \limits_{n=1}^{\frac{p-1}{2}}n·\prod \limits_{n=1}^{\frac{p-1}{2}}n=\prod \limits_{n=1}^{\frac{p-1}{2}}n·\prod \limits_{n=1}^{\frac{p-1}{2}}-n \equiv\prod \limits_{n=1}^{\frac{p-1}{2}}n·\prod \limits_{n=\frac{p+1}{2}}^{p-1}n=(p-1)! \equiv 1$

You can change $n$ for $-n$ because there is an even number of factors from $1$ to $\frac{n-1}{2}$

Therefore, $\frac{p-1}{2}!$ is congruent to either $1$ or $-1$

Wilson's theorem

$$(p-1)!\equiv_p -1$$

Proof: Every element $$x\in\Bbb Z_p^\times$$ has a unique inverse $$y\in\Bbb Z_p^\times$$ such that $$xy\equiv_p 1$$, except $$-1,1$$ since they are their own inverses, i.e., they satisfy $$x^2\equiv_p 1$$.

This inverse is unique, since if both $$y,y'$$ were inverses of $$x$$, then $$xy\equiv_p xy'\equiv_p 1\Rightarrow y\equiv_p y'$$ Now in the product $$(p-1)!$$ every element is multiplied with it's corresponding inverse, except $$-1$$ and $$1$$, which means $$(p-1)!\equiv_p 1\cdot 1\cdot\ldots\cdot 1\cdot (-1)\equiv_p -1$$

$$(p-1)!\equiv_p 1\cdot (-1)\cdot 2\cdot (-2)\cdot \ldots\cdot \frac{p-1}{2}\cdot (-\frac{p-1}{2})\equiv_p (-1)^{\frac{p-1}{2}}\left (\frac{p-1}{2}\right )!^2$$

By Wilson's theorem $$-1\equiv_p(-1)^{\frac{p-1}{2}}\left (\frac{p-1}{2}\right )!^2$$

Using that $$p\equiv_4 3$$ we get $$\left (\frac{p-1}{2}\right )!\equiv_p \pm1$$

• Could you explain me the last part? I don’t see how using $p \equiv 3 \pmod 4$ you obtain that result. Thank you – Octavio Berlanga Aug 5 at 22:17
• @OctavioBerlanga If $p\equiv_4 3$ then $(-1)^{\frac{p-1}{2}}=-1$, thus you get $1\equiv_p \left(\frac{p-1}{2}\right)!^2$. Are you satisfied? – cansomeonehelpmeout Aug 6 at 12:34
• I am satisfied, thank you. – Octavio Berlanga Aug 6 at 16:20