Number of integer solutions to $x^2 + xy + y^2 = c$ Inspired by this question on Mathematica StackExchange:
Consider the set of integer solutions $x, y \in \mathbb{Z}$ to the equation $x^2 + xy + y^2 = m$, for $m \in \mathbb{N}$.  Conjecture: the number of distinct solutions to this equation is divisible by 6 for all integer $m$.
I have done a brute-force calculation in Mathematica for $m \leq 10^4$, and have not found any counterexamples. For example, there are:

*

*0 integer solutions for $m = 2$;

*6 distinct solutions for $m = 3$ [$(x,y) = \pm (2, -1)$, $(x,y) = \pm (-1, 2)$, and $(x,y) = \pm (1, 1)$];

*12 distinct solutions for $m = 7$;

*18 distinct solutions for $m = 49$;

and so forth.  The largest number of solutions Mathematica found was 54 solutions, for $m = 8281$.  All of these are divisible by 6.
Is there a counterexample to this conjecture for some larger value of $m$?  Or can the conjecture be proven?
I suspect that a proof will involve some kind of hidden symmetry of the polynomial $x^2 + xy + y^2$ that maps integer solutions to integer solutions;  but I haven't been able to nail it down.  It's not hard to see that the number of solutions must be even (if $(x,y)$ is a solution, then so is $(-x, -y)$, and these are distinct unless $x = y = 0$);  but the divisibility by 6 is much more mysterious to me.
 A: This is a slightly different approach to your problem. Let $\omega$ be the cube root of unity. Then
$$x^2+xy+y^2=(x-\omega y)(x-\omega^2 y)=m.$$
If this has a solution, then it means there exists an element $\alpha=x-\omega y$ in the ring $\Bbb{Z}[\omega]$ such that its norm $N(\alpha)=m$. But if you consider the six units of the ring $\Bbb{Z}[\omega]$, they are $\{\pm 1, \pm \omega, \pm \omega^2\}$, then the norm of $\alpha u$, where $u$ is a unit is also $m$. So for every solution $\alpha$ you have six solutions namely, $\pm\alpha, \pm\omega \alpha, \pm \omega^2 \alpha$.
A: Observe that,
$$(x+y)^2+(x+y)(-y)+(-y)^2=x^2+2xy+y^2-xy-y^2+y^2=x^2+xy+y^2$$
Therefore $(x,y)$ is a solution then so is $(x+y,-y)$.
We consider the following cases
Case 1
When $x=y=k$ then $$(k,k), (-k,-k), (2k,-k), (-2k,k), (-k,2k), (k,-2k)$$ are $6$ distinct solutions.
Case 2
If $y=0$ but $x\neq0$ then $$(x,0),(-x,0),(x,-x),(-x,x),(0,x),(0,-x)$$ are $6$ distinct solutions. This also works when $x=-y$.
Case 3
Otherwise, for $|x|\neq |y|$ and $xy\neq 0$, $$(x,y),(-x,-y),(y,x),(-y,-x),(x+y,-y),(x+y,-x),(-x-y,x),(-x-y,y),(-x,x+y),(-y,x+y),(x,-x-y),(y,-x-y)$$ are all $12$ distinct solutions.
A: If $(x,y)$ is a solution then so are all of
$$\{(x,y),(-x,-y),(y,x),(-y,-x),(-x,x+y),(x,-x-y)\}$$
which are all distinct unless $x$ and $y$ fall within a set of the form
$$\{(z,z),(-z,-z),(-z,2z),(z,-2z),(2z,-z),(-2z,z)\}$$
so that we always have a multiple of $6$ solutions.
