Divisors of numbers of the form $a^2+2b^2$ with $\gcd(a,b)=1$ Let's say I have a number $n$ which can be written as $a^2+2b^2$ for integers $a,b$. By Fermat/Euler/etc., I know that the primes dividing the squarefree kernel of $n$ cannot be congruent to $5$ or $7$ modulo $8$. But does the additional restriction $\gcd(a,b)=1$ give me any additional information? My intuition (and some brute-force searches) leads me to believe that no prime — even a prime to an even power — dividing $n$ can be congruent to $5$ or $7$ modulo $8$.
 A: You are correct, if $\gcd(a,b)=1$ and $p\mid a^2+2b^2$ then $p$ is not a factor of $b$, so $\left(\frac{a}{b}\right)^2=-2\pmod p$, so $-2$ must be a square modulo $p$, which is possible exactly when $p=2$ or $p\equiv 1,3\pmod 8$.
Since $\mathbb Z[\sqrt{-2}]$ is a unique factorization domain, you can use the same argument that we use for the two square theorem to show that every number with no prime factors $p\equiv 5,7\pmod 8$can be written as $a^2+2b^2$.
A: Given $$ f(x,y) = a x^2 + b x y + c y^2   $$ with
$$  \Delta = b^2 - 4 a c $$ which, if non-negative, is not allowed to be $0$ or $1$ or any square. Also demand $\gcd(a,b,c) = 1.$
Theorem. Given odd prime $q$  that does not divide $\Delta,$ with
$ (\Delta|q) = -1,  $ whenever
$$  f(x,y) \equiv 0 \pmod q, $$
then 
$$   x,y \equiv 0 \pmod q $$ THEREFORE
$$  f(x,y) \equiv 0 \pmod {q^2}. $$
PROOF: by the hypothesis, $a$ is not divisible by $q.$ Multiply through by $4a$ and complete the square. 
In comparison, for odd primes $p$ not dividing the discriminant, with  $ (\Delta|p) = +1,  $ there are no restrictions. This is, for example, Lemma 2.4 on page 58 of CASSELS, inexpensive reprint and very good.
The prime $2$ and primes dividing the discriminant should be handled separately. There are also general rules but more is going on. 
