# For which primes is $-2$ a quadratic residue?

For which primes is $-2$ a quadratic residue?

We are trying to find primes that have solution for $x^2 \equiv -2 \mod p.$ Using the Lagrange symbol I know that $2$ is a quadratic residue when $p \equiv 1$ or $7 \mod 8,$ but when is $-2$ a quadratic residue?

Work so far:

$\left(\dfrac{-2}{p} \right) = \left(\dfrac{-1}{p} \right)\left(\dfrac{2}{p} \right).$

We have that

$\left(\dfrac{-1}{p}\right) = \begin{cases} 1 & : p \equiv 1 \pmod{8} \text{ or } p \equiv 5 \pmod{8} \\ -1 & : p \equiv 3 \pmod{8} \text{ or } p \equiv 7 \pmod{8} \end{cases}$

and

$\left(\dfrac{2}{p} \right) = \left\{ \begin{array}{lr} 1 & : p \equiv 1 \pmod 8 \text{ or } p \equiv 7 \pmod 8 \\ -1 & : p \equiv 3 \pmod 8 \text{ or } p \equiv 5 \pmod 8 \end{array} \right.$

If $p \equiv 5 \pmod 8,$ then $\left(\dfrac{-2}{p} \right) = \left(\dfrac{-1}{p} \right)\left(\dfrac{2}{p} \right) = 1 \cdot -1 = -1,$ so $-2$ is not a quadratic residue for this particular case. If $p \equiv 7 \mod 8,$ then $\left(\dfrac{2}{p} \right) = 1$ and $\left(\dfrac{-1}{p} \right) = -1 \Longrightarrow \left(\dfrac{-2}{p} \right) = -1 \cdot 1 = -1.$ Hence $-2$ is not a quadratic residue in this particular case either. But if $p \equiv 1 \mod 8$ or $p \equiv 3 \mod 8,$ then $\left(\dfrac{-2}{p} \right) = 1 \cdot 1 = 1$ or $\left(\dfrac{-2}{p} \right) = -1 \cdot -1 = 1.$ Thus $-2$ is a quadratic residue for primes congruent to $1$ or $3$ modulo $8.$

## 1 Answer

Hint: $$\left(\frac{-1}{p}\right) = \begin{cases} 1 & : p \equiv 1 \pmod{8} \text{ or } p \equiv 5 \pmod{8} \\ -1 & : p \equiv 3 \pmod{8} \text{ or } p \equiv 7 \pmod{8} \end{cases}$$

• How is my answer? Thanks for the hint. – user167857 May 18 '15 at 5:31
• Looks fine to me. – Yuval Filmus May 18 '15 at 5:33