Take the 2-minute tour ×
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.

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|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.

1 Answer 1

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|improve this answer

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