# When does $x^2+2y^2 =p$ have a solution in integers?

Show that $x^2+2y^2=p$ has a solution in $\mathbb{Z}\;$ if and only if $\;p \equiv 1 \; \text{or} \; 3 \mod 8$.

Can someone help on this. Thnx.

-
–  MJD Jun 8 '13 at 14:17
Have you tried showing each direction $\Rightarrow$ and $\Leftarrow$ in turn? Which direction are you stuck on? It would also help to know what you've tried, and what previous knowledge you have. –  Goos Jun 8 '13 at 14:22
I proved that if $p=x^2+y^2$ then $(p)=(x+iy)(x-iy)$ in $\mathbb{Z}[i]$ so $p \equiv 1 \mod 4$ –  Vali Jun 8 '13 at 14:37
@Vali You can do this question similarly but you'll need to work in $\mathbb{Z}[\sqrt{-2}]$ –  Cocopuffs Jun 8 '13 at 14:41

## 1 Answer

One direction: if $x^2+2y^2=p$ then $x^2\equiv -2y^2\pmod{p}$. But $\gcd(y,p)=1$ so $(x/y)^2\equiv -2\pmod{p}$. Hence $1=\left(\frac{-2}{p}\right)=\left(\frac{2}{p}\right)\left(\frac{-1}{p}\right)=(-1)^{\frac{(p+1)(p-1)}{8}}(-1)^{\frac{p-1}{2}}$ which implies $p\equiv 1,3\pmod{8}$.

-