Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

Possible Duplicate:
Why is the square of all odds less than an odd prime $p$ congruent to $(-1)^{(p+1)/(2)}\pmod p$?

Why is $3^2 \ 5^2 \ldots (p-2)^2 \equiv (-1)^{\frac{p+1}{2}} \ (\mathrm{mod} \ p)$, where $p$ is an odd prime?

I can't seem to figure it out. Any help would be appreciated. Thanks!

share|cite|improve this question

marked as duplicate by Gerry Myerson, sdcvvc, t.b., William, J. M. Sep 25 '12 at 2:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 5 down vote accepted

Since $a\equiv -(p-a)\pmod{p}$, we can write

\begin{align} 3^2 \cdot 5^2 \cdots (p-2)^2&\equiv \left(3\cdot 5\cdots (p-2)\right)\times\left((p-3)\cdot (p-5)\cdots 2\right)\times (-1)^{(p-3)/2}\\ &\equiv (-1)^{(p-3)/2}(2\cdot 3\cdots (p-2))\cdot (p-1)\cdot (p-1)\\ &\equiv (-1)^{(p-1)/2}(p-1)!\\ &\equiv (-1)^{(p+1)/2}\pmod{p}, \end{align} where in the third step we introduced a factor of $(p-1)(p-1)\equiv -1\cdot -1\equiv 1$, and in the last step we used Wilson's Theorem.

share|cite|improve this answer

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