What is $\left[\frac{1}{2}(p-1)\right]! \;(\text{mod } p)$ for $p = 4k+1$? Theorem #114 in Hardy and Wright says if $p = 4k+3$ then
$$ \left[\frac{1}{2}(p-1)\right]!  \equiv (-1)^\nu \mod p$$
where $\nu = \# \{ \text{non residues mod } p\text{ less than }p/2\}$. 


*

*Is there corresponding result for $p = 4k+1$?  


In that case, Hardy just says the factorial is one $\pm \sqrt{-1} \in \mathbb{Z}_p$ but he doesn't say which one.  When is this value greater than or less than $\frac{p}{2}$ ?


*

*How do we estimate the number $\nu$ of quadratic residues mod p? 


Maybe this paper of Burgess on the distribution of quadratic residues will help.

In $\mathbb{F}_p^*$ there are exactly $\frac{p-1}{2}$ quadratic residues, and if $p\equiv 1\pmod{4}$, $-1$ is a quadratic residue, hence the quadratic residues are symmetrically distributed around $\frac{p}{2}$, so the number of quadratic residues less than $\frac{p}{2}$ is just $\frac{p-1}{4}$.
