When the expression $p^2 - pq + q^2$ is divisible by 3?

651 Views Asked by At

Let $p$ and $q$ be integers in a fixed range $[0, N]$. Is there an easy way to say when $p^2 - pq + q^2$ is divisible by 3? More or less, I need to find the probability that, if $q$ and $p$ are picked randomly from the set above, the expression is divisible by 3. Could you please help me?

1

There are 1 best solutions below

3
On BEST ANSWER

$p^2 - pq + q^2 = (p+q)^2 - 3pq$
Then we conclude that if and only if $p+q$ is divisible by 3, the expression is divisible by 3