# 1/2 Wilson's theorem

During my research I came across this question :

Question: What's the value of $$x_p=(\dfrac{p-1}{2})! \mod p$$ when $$p>3$$ is prime ?

Remark: It's easy to see $$x_p^2 \mod p=(-1)^{\dfrac{p+1}{2}} \mod p$$ with $$x_p\in [1;p-1] \cap \mathbb N$$

But it's not easy to find if $$x_p \leq\dfrac{p-1}{2}$$ or $$x_p> \dfrac{p-1}{2}$$

• – dhy
Mar 29, 2019 at 13:19
• He talks about the case $p \mod 4=3$ what about the other case ? Mar 29, 2019 at 13:29
• See OEIS sequence A004055 for programs and the first 9999 terms. Mar 29, 2019 at 14:04
• If you change the generator $b$ and replace it (for example) by $1/b$ then the sign you are interested in changes. So I think in the case p=1 mod 4, it does not really make sense to ask about this sign, as there is no canonical generator of $\mathbb{F}_p^{\times}$ Mar 29, 2019 at 14:43
• Nevertheless you could define a kind of canonical square root of -1 by using a decomposition $p=a^2+b^2$, say $a/b$ with $a <b$. But you see it depends on some choices, which could turn out to be arbitrary Mar 29, 2019 at 14:51

For the case $$p\equiv 1\pmod{4}$$, see the following paper of Chowla: On the class number of real quadratic fields. Proc. Nat. Acad. Sci. U.S.A. 47 (1961), 878. There the following is proved:
Let $$h$$ be the class number of $$\mathbb{Q}(\sqrt{p})$$, and let $$\epsilon = (u+v\sqrt{p})/2$$ be the fundamental unit of the corresponding ring of integers. Then $$h$$ is odd and $$2\cdot \frac{p-1}{2}! \equiv (-1)^{(h+1)/2} u \pmod{p}.$$
• And $x_p=+-\sqrt{-1}$ when $p \mod 4=1$ Mar 29, 2019 at 13:20