# If $x^2+y^2=z^2$, why can't $x$ and $y$ both be odd?

What does the following mean: If $x^2 + y^2 = z^2$ some integers $z$, then $x$ and $y$ can't be both odd (otherwise, the sum of their squares would be $2$ modulo $4$, which can't be a square). So, one of them must be even?

I see that if x and y are both odd, then $z^2 = 4k+2 =2(2k+1)$. So $z^2$ is even. But why does it say above that... can't be square?

• Are you looking for integers where $x^2+y^2=z^2$? – Henry Oct 25 '11 at 19:31
• – Henry Oct 25 '11 at 19:34
• Because if $z^2$ is even, then $z$ is also even... And then $z^2=z \cdot z$ is the product of two even numbers, thus it has $4$ as a divisor.. – N. S. Oct 25 '11 at 19:38

If $n = 2k$, then $n^2 = 4k^2$ is a multiple of $4$.

Likewise, if $n = 2k+1$, then $n^2 = 4(k^2 + k) + 1$.

Therefore, a square is congruent to either $0$ or $1 \pmod{4}$. In other words, a square is never of the form $4k + 2$, for some $k$.

More specifically, since you've seen that $x^2 + y^2 \equiv 2 \pmod{4}$ when $x$ and $y$ are odd, and since squares are never congruent to $2 \pmod{4}$, this shows that $x^2 + y^2$ is never a square when $x$ and $y$ are both odd.

Working modulo $4$, $0^2\equiv 2^2 \equiv 0 \pmod {4}$. This means that all even squares are multiples of $4$. But if $x$ and $y$ were both odd, $x^2+y^2\equiv 2 \pmod 4$, which cannot be a square. You can try squaring small even numbers and note that all the squares are multiples of $4$

• What do you mean by saying: either of these? Do you mean x and y? What do you mean by saying: multiple of 4? Do you mean $z^2 = 4 k$? And what you mean b saying: not two more than a multiple of 4? Do you mean that not x and y plus other variable are multiple of 4(x=4k, y=4l, variable=4m)? – user2723 Oct 25 '11 at 19:39
• @alvoutila: did you see my previous answer? I have replaced it. Maybe user9176 said it best in his comment. – Ross Millikan Oct 25 '11 at 19:42
• I'm maybe repeating myself, but I ask anyhow. If x and y are both odd, how do you get from $x^2+y^2≡2 \pmod 4$ that it cannot be square? – user2723 Oct 25 '11 at 20:08
• @alvoutila: There are two cases: even ($x=2k$) and odd ($x=2k+1$). If $x$ is even, $x^2=4k^2=0\pmod{4}$. If $x$ is odd, $x^2=(2k+1)^2=4k^2+4k+1=1\pmod{4}$. Thus, the only squares $\pmod{4}$ are $0$ and $1$. If both $x$ and $y$ are odd, $x^2+y^2=2\pmod{4}$ and that cannot be a square. – robjohn Oct 25 '11 at 21:16

Alvoutila- they have shown you that squares of even numbers are multiples of 4, and that squares of odd numbers are of form $4k+1$... Summing two of the latter will result in number $(4k+1)+(4l+1) = 4(k+l)+2$, and that cannot be neither square of even number (not a multiplier of 4) nor of odd number (of form $4m+1$ and not $4m+2$).