Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I came across the two congruences that for $p$ an odd prime,

$$1^2\cdot 3^2\cdot 5^2\cdots (p-2)^2\equiv (-1)^{(p+1)/(2)}\pmod p$$


$$2^2\cdot 4^2\cdot 6^2\cdots (p-1)^2\equiv (-1)^{(p+1)/(2)}\pmod p$$

What is the reason for this? It seems to me to be closely related to Wilson's Theorem, and possibly Fermat's little theorem since $p-1=2k$ for some $k$, and then $j^{2k}\equiv 1\pmod p$ for all the evens and odds $j$ less than $p$, but I wasn't able to complete this train of thought.

share|cite|improve this question
up vote 3 down vote accepted

Modulo $p$, you have $k=-(p-k)$ and so both products are equal to $(p-1)!(-1)^{(p-1)/2} \equiv (-1)^{(p+1)/2} \pmod{p}$ by Wilson's theorem.

share|cite|improve this answer
Pardon me if I'm mistaken, but did you mean to say modulo $p$, $k=k-p$? Then I see that $1^2\cdot 2^2\cdot 3^2\cdots (p-2)^2\equiv (1)(1-p)(2)(2-p)\cdots (p-2)(-2)\equiv (p-1)!(-1)^{(p-1)/2}\pmod p$. – yunone Sep 17 '10 at 2:22
Got me! oops... – Yuval Filmus Sep 17 '10 at 3:22
Regardless, thank you for pointing me in the right direction. – yunone Sep 17 '10 at 4:18

I amplify the details -

The crux is to use $\color{purple}{ p-k\equiv -k \mod p }$.

$ [ 2 \cdot 4 ... (p - 3) \cdot (p-1)] \cdot \quad \color{purple}{[ 2 \cdot 4 ... (p - 3) \cdot (p-1)]} $ $\equiv [ 2 \cdot 4 ... (p - 3) \cdot (p-1)] \cdot \quad \color{purple}{[ (p-2) \cdot (p-4) ... \cdot (1) \quad \cdot (-1)^\frac{p-1}{2}]} (\mod p) = (p - 1)! \quad \cdot (-1)^\frac{p-1}{2} \equiv -1 \quad \cdot (-1)^\frac{p-1}{2} \quad (mod p)$

The last line is by reason of Wilson's Theorem.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.