Consider the equation $a^2+ab+b^2=1$. How many integer pairs are solutions to this?
I found 4 pairs: $a=-1, b=0$; $a=0, b=-1$; $a=1,b=0$; $a=0, b=1$.
But the solution says the answer is 6. Which other possibilities am I missing? Please post the answer with solution.
If $b=0$ then it gives $a=\pm1$. If $b=1$ then $a=0$ or $a=-1$ and if $b=-1$ then $a=0$ or $a=1$. Otherwise, you will have
which is impossible.
So, the solutions are
(there are 6 solutions as you wanted)
Note that you can complete the square in $a^2+ab+b^2=1$to get $$\left(a+\frac b2\right)^2+\frac 34b^2=1$$
Now you can see that the sum of the two positive terms can only be equal to $1$ if the terms themselves are less than or equal to $1$. This means that $|b|\leq 1$ and by symmetry $|a|\leq 1$.
If $a=0$ then $b=\pm 1$ and if $b=0$ then $a=\pm 1$. What happens if neither $a$ nor $b$ is zero – say $a=1$ – what solutions do you find then?