I was looking at Wilson's theorem: If $P$ is a prime then $(P-1)!\equiv -1\pmod P$. I realized this
implies that for primes $P\equiv 3\pmod 4$, that $\left(\frac{P-1}{2}\right)!\equiv \pm1 \pmod P$. 


Question: For which primes $P$ is $\left(\frac{P-1}{2}\right)!\equiv 1\pmod P$?


After convincing myself that it's not a congruence condition for $P,$ I found [this sequence in OEIS](http://oeis.org/A058302). I'd appreciate any comments that shed light on the nature of such primes (for example, they appear to be of density 1/2 in all primes that are $3\bmod 4$).


Thanks,


Jacob



Primes P such that ((P-1)/2)!=1 mod P
I am a newcomer here. If p >3 is congruent to 3 mod 4, there is an answer which involves only $p\pmod 8$ and $h\pmod 4$, where $h$ is the class number of $Q(\sqrt{-p})$ .
Namely one has $(\frac{p-1}{2})!\equiv 1 \pmod p$ if an only if either (i) $p\equiv 3 \pmod 8$ and $h\equiv 1 \pmod 4$ or (ii) $p\equiv 7\pmod 8$ and $h\equiv 3\pmod 4$.


The proof may not be original: since $p\equiv 3 \pmod 4$, one has to determine the Legendre symbol


$${{(\frac{p-1}{2})!}\overwithdelims (){p}}
=\prod\_{x=1}^{(p-1)/2}{x\overwithdelims (){p}}=\prod\_{x=1}^{(p-1)/2}(({x\overwithdelims (){p}}-1)+1).$$ It is enough to know this modulo 4 since it is 1 or -1. By developping, one gets $(p+1)/2+S \pmod 4$, where 
$$S=\sum\_{x=1}^{(p-1)/2}\Bigl({x\over p}\Bigr).$$ By the class number formula, one has $(2-(2/p))h=S$ (I just looked up Borevich-Shafarevich, Number Theory), hence the result, since $\Bigl({2\over p}\Bigr)$ depends only on $p \pmod 8$.


Edit: For the correct answer see KConrad's post or Mordell's article. 


