Let $p$ be an odd prime; and $a$ and $b$ are integers with $1\leq a, b \leq \dfrac{p-1}{2}$.
Is it true that
$p \mid a^2+ab+b^2 \text{ (for some choice of } a \text{ and } b) \iff p \not \equiv 2 \pmod{3},$
or equivalently,
$p \not\mid a^2+ab+b^2 \text{ (for no choice of } a \text{ and } b)\iff p \equiv 2 \pmod{3}?$
I'm totally stuck! Quite new in Number Theory.
Any help will be much appreciated.
You are slightly off, as since $$1^2+1 \times 1 +1^2 \equiv 0 \pmod 3$$ $p=3$ is posible as well. This can be proved as follows. $$a^2+ab+b^2 \equiv 0 \pmod p \implies (2a+b)^2+3b^2 \equiv 0 \pmod p$$ Thus, if $b^{*}$ is modulo inverse of $b$ modulo $p$, then we have that $$(2ab^{*}+1)^2 \equiv -3 \pmod p$$ So $-3$ is a quadratic residue of $p$, so we have that $p \equiv 1 \pmod 3$ or $p=3$. For why this is true, see here.