Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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

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.

share|cite|improve this question
Relevant: The sum of a square and twice a square – 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. – 6005 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

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

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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