# General elementary prime numbers divisibility question

Let $a, b$ be non-negative integers and $p\ge3$ be a prime number. If $a^2+b^2$ and $a+b$ are divisible by $p$ does it mean $a$ and $b$ are always divisible by $p$?

• Yes, it is true. Try to show that $a-b$ is also divisible by $p$, from the fact that $(a-b)^2$ is a multiple of $p$. Note that this is not true for $p = 2$. – астон вілла олоф мэллбэрг Oct 5 '17 at 0:11
• Note that $a^2+b^2=(a+b)^2-2ab$ and use Euclid's lemma to conclude that $p$ must divide $a$ or $b$. – Prasun Biswas Oct 5 '17 at 0:20

Suppose $p$ be an odd prime.
Note that $a^2+b^2=(a+b)^2-2ab$ and use Euclid's lemma to conclude that $p$ must divide $a$ or $b$.
Now, assume that only one of $a,b$ (WLOG say $a$) is divisible by $p$.
Since $p\mid a+b$ and $p\mid a$, we get $p\mid (a+b)-a=b$, i.e., $p\mid b$, a contradiction.
Since $a+b\equiv 0 \bmod p$, we have $a\equiv -b$ and thus $a^2\equiv b^2 \bmod p$.
Then $a^2+b^2\equiv 2a^2 \equiv 0 \bmod p$ and since $p>2$ we know $p\mid a^2$ and thus $p\mid a$ and $p\mid b$.