0

If $p$ is a prime. Then $x^{2} \equiv-1\ \pmod p$ has a solution if and only if $p\equiv 1\ \pmod 4$. Please explain in the easiest way.

mnulb
  • 3,701

2 Answers2

8

I assume you mean odd primes.

If $$p \equiv 1 \pmod 4 \Rightarrow \left(\left(\frac{p-1}{2}\right)!\right)^2 \equiv -1 \pmod p (\because \text{Wilson's Theorem})$$ So we have shown that if $p \equiv 1 \pmod 4$, $x^2 \equiv -1 \pmod p$ exists.

Now let us show that if $x^2 \equiv -1 \pmod p$, then $p \equiv 1 \pmod 4$. If $$x^2 \equiv -1 \pmod p \Rightarrow (x^2)^{\frac{p-1}{2}} \equiv (-1)^{\frac{p-1}{2}} \equiv 1 \pmod p $$ By Fermat's Little Theorem.

Thus we have $\frac{p-1}{2} \equiv 0 \pmod 2$, and $p \equiv 1 \pmod 4$.

S.C.B.
  • 23,106
  • Is this special case of Wilson's theorem? – mnulb May 11 '16 at 14:35
  • @Ayushakj That depends on how you define "special case", but $$\left(\left(\frac{p-1}{2}\right)!\right)^2 \equiv (-1)^{\frac{p+1}{2}} \pmod p $$ using $-x \equiv p-x \pmod p$. – S.C.B. May 11 '16 at 14:37
  • @Ayushakj fixed. – S.C.B. May 11 '16 at 14:38
  • how u got: $\frac{p-1}{2} \equiv 0 \pmod 2$ – mnulb May 11 '16 at 14:54
  • @Ayushakj $p \equiv 1 \pmod 4$. – S.C.B. May 11 '16 at 16:01
  • @S.C.B. Hi, old question but can you please show how do you get this implication using Wilson's Theorem: $p\equiv1\quad(\mathrm{mod} 4)\Rightarrow\left(\left(\frac{p-1}{2}\right)!\right)^2\equiv-1\quad(\mathrm{mod} p)$? – Arbatus Nov 16 '24 at 22:22
  • @Arbatus Note that $1 \times 2 \times \cdots \left( \frac{p-1}{2} \right) \times \left(\frac{p+1}{2}\right) \times \cdot (p-2) \times (p-1) \equiv -1 \pmod{p}$ by Wilson's theorem. The $\frac{p+1}{2} = p - \frac{p-1}{2}$ and so on. Removing each of the $p$, we have $1 \times 2 \times \cdots \left( \frac{p-1}{2} \right) \times \left(- \frac{p-1}{2}\right) \times \cdot (-2) * (-1)$. Separating out $(-1)^{\frac{p-1} {2}}$ which is $1$ when $p \equiv 1 \pmod{4}$, we arrive at the desired result. – S.C.B. Nov 19 '24 at 07:11
  • @Arbatus This explains it nicely. – S.C.B. Nov 19 '24 at 07:12
3

Here is a simple proof using group theory and the fact that $U(p)$ is cyclic. Assume $p$ is odd.

$x^{2} \equiv-1 \bmod p$ has a solution if and only if $U(p)$ has an element of order $4$.

Since $U(p)$ is a cyclic group, this happens iff $4$ divides the order of $U(p)$, which is $p-1$.

lhf
  • 221,500