Can an integer of the form $4n+3$ written as a sum of two squares?

Let $u$ be an integer of the form $4n+3$, where $n$ is a positive integer. Can we find integers $a$ and $b$ such that $u = a^2 + b^2$? If not, how to establish this for a fact?


Lemma 1: $a$ is odd $\Longrightarrow$ $a^2\equiv 1(\operatorname{mod} 4)$.

Proof: $a^2-1=(a-1)(a+1)$. Since $a$ is odd, both $a-1$ and $a+1$ are even, so that $a^2-1$ is divisible by $4$. $\blacksquare$

Lemma 2: $a$ is even $\Longrightarrow$ $a^2\equiv 0(\operatorname{mod} 4)$.

Proof: Trivial. $\blacksquare$

Now, suppose that $u=a^2+b^2$.

(1) If both $a$ and $b$ are even, then $u$ is divisible by four by lemma 2.

(2) If both $a$ and $b$ are odd, then $u\equiv 2(\operatorname{mod}4)$ by lemma 1.

(3) If $a$ is even and $b$ is odd (wlog), then $u\equiv1(\operatorname{mod}4)$ by lemmas 1 and 2.

That is, it is never the case that $u\equiv 3(\operatorname{mod} 4)$.


I'll write another argument with more group theoretic flavor in my opinion. Suppose that $p=4k+3$ is a prime number and you can write $p=x^2+y^2$. then $x^2+y^2 \equiv 0 \pmod{p} \iff x^2 \equiv -y^2 \pmod{p} \iff (xy^{-1})^2 \equiv -1 \pmod{p}$. Therefore $t=xy^{-1}$ is a solution of $x^2 \equiv -1 \pmod{p}$.

Now consider the group $\mathbb{Z}^*_p$ which consists of all non-zero residues in mod $p$ under multiplication of residues. $|G|=(4k+3)-1=4k+2$. Therefore, by a group theory result (you can also use a weaker theorem in number theory called Fermat's little theorem), for any $a \in \mathbb{Z}^*_p: a^{|G|}=1$, i.e. $a^{4k+2}=1$.

We know that there exists $x=t$ in $\mathbb{Z}^*_p$ such that $x^2 = -1$, hence, $x^4 = 1$. But this means that $\operatorname{ord}(x) \mid |G| \implies 4 \mid 4k+2$. But $4 \mid 4k$ and therefore $4 \mid 4k+2 - 4k = 2$ which is absurd. This contradiction means that it's not possible to write $p=x^2+y^2$ for $x,y \in \mathbb{Z}$.

EDIT: I should also add that any integer of the form $4k+3$ will have a prime factor of the form $4k+3$. The reason is, if none of its factors are of this form, then all of its prime factors must be of the form $4k+1$. But you can easily check that $(4k+1)(4k'+1)=4k''+1$ which leads us to a contradiction. This is how you can generalize what I said to the case when $n=4k+3$ is any natural number.


For any integer n, n = 0, 1, 2 or 3 (mod 4). So $n^{2}$ = 0 or 1 (mod 4). Then for any integers a and b, $a^{2} + b^{2}$ = 0, 1 or 2 (mod 4). This means the sum of two squares can only be in the form 4k, 4k+1 or 4k+2, but never 4k+3. Thus no integer of the form 4k+3 is the sum of two squares.