
> 
> **Possible Duplicate:**  
> 
> [Primes P such that ((P-1)/2)!=1 mod P](https://mathoverflow.net/questions/16141/primes-p-such-that-p-1-21-mod-p) 
> 
> 
> 


Motivation comes from comments in [this question](https://mathoverflow.net/questions/30101/composite-pairs-of-the-form-n-1-and-n1), and it is interesting in its own right. These primes are sequence [A055939](http://www.research.att.com/~njas/sequences/A055939) in OEIS.


So, which primes $p$ satisfy $p\\ |\\ (\frac{p-1}{2})! + 1$?


If my calculations (in sage) are correct, the following is true for all primes under 100,000. For $p > 3$:
$$p\\ |\\ (\frac{p-1}{2})! + 1 \iff h(\sqrt{-p})=1 \mod{4}$$



Primes p such that p | ((p-1)/2)! + 1
Yes, this follows from the analytic class number formula.
See
<http://www.math.niu.edu/~rusin/known-math/97/sign> .


**Added** I have now found a reference. This is a theorem of Mordell:


L. J. Mordell, 
The congruence $(p - 1/2)! \equiv \pm 1 (\operatorname{mod} p)$,
*American Mathematical Monthly*, **68** (1961), 145-146.
<http://www.jstor.org/stable/2312481>


