TITLE: If $a$ and $b$ are integers such that $9$ divides $a^2 + ab + b^2$ then $3$ divides both $a$ and $b$.
QUESTION [5 upvotes]: If $a$ and $b$ are integers such that $9$ divides $a^2 + ab + b^2$ then show that $3$
divides both $a$ and $b$.

can anyone tell me please how to solve these types of problem oe which formula is required

REPLY [2 votes]: The divisibility is equivalent to $$3^2\mid 4(x^2+xy+y^2)=(2x+y)^2+3y^2$$. Since $3\mid 3y^2$ then $3\mid (2x+y)^2$. But $(2x+y)^2$ is a square so $3^2\mid (2x+y)^2$, implying that $3^2\mid 3y^2$, i.e. $3\mid y$. Together with $3\mid 2x+y$ we get also $3\mid x$.