(Two Squares Theorem) Show that a positive integer $n$ is a sum of two squares if and only if each prime factor $p$ of $n$ such that $p\equiv 3\pmod{4}$ occurs to an even power in the prime factorization of $n$.
First let $n=s^2m$ where both $s$ and $m$ are positive integers, and none of $m$'s divisor greater than $1$ is a square.
If every prime factor $p\equiv 3\pmod{4}$ occurs an even power in the prime factorization of $n$, all prime factors $p > 2$ of $m$ must be in the form of $p\equiv 1\pmod{4}$. By # 4188, we know all of these prime factors can be written as a sum of two squares. Meanwhile, it is clear that $2=1^2+1^2$. Therefore $m$ can be written as a product of several sum of squares.
We know that a product of two sums of squares can be written as a sum of two squares (see # 4189). Thus, $m$ can always be expressed as a sum of two squares. Let $m=x^2 + y^2$ where both $x$ and $y$ are integers. This implies $n=s^2m=(sx)^2 + (sy)^2$.
On the other hand, if $n$ is a sum of two squares, let it be $x^2 + y^2$. If $m=1$, then $n=s^2$. In this case, all prime factors occurs even power in the prime factorization of $n$. Therefore it is sufficient to show that if $m > 1$, every odd prime factor $p$ of $m$ must satisfy $p\equiv 1\pmod{4}$.
Let $d$ be the greatest common divisor of $x$ and $y$. Then there exist two co-prime integers $x_1$ and $y_1$ such that $x=dx_1$ and $y=dy_1$. It follows that $$n=d^2(x_1^2 + y_1^2)\implies \frac{s^2m}{d^2}=x_1^2+y_1^2$$
Because $m$ does not have any square divisor, we must have $d^2\mid s^2$. Let's assume $s^2=t\cdot d^2$ where $t$ is an integer. Then $$tm=x_1^2 + y_1^2$$
If $p$ is a prime factor of $m$, then we must have $p\mid x_1^2 + y_1^2$ or $$x_1^2 + y_1^2\equiv 0\pmod{p} \implies x_1^2\equiv -y_1^2\pmod{p}$$
If $p\not\equiv 1\pmod{4}$, then $p\equiv 3\pmod{4}$ or $p=4k+3$ where $k$ is an integer. Noting that $p-1=2\times(2k+1)$, we have $$\begin{array}{rcll} x_1^2 &\equiv& -y_1^2 &\pmod{p} \\ \left(x_1^2\right)^{2k+1} &\equiv&-\left(y_1^2\right)^{2k+1}&\pmod{p} \\ x_1^{p-1}&\equiv& -y_1^{p-1}&\pmod{p} \end{array}$$
We note that $p$ cannot divide either $x_1$ or $y_1$. If this conclusion does not hold, then $p$ must divide both $x_1$ and $y_1$ because $p\mid x_1^2 + y_1^2$. This will contradict to the fact that $x_1$ and $y_1$ are co-prime. If $p$ divides neither $x_1$ nor $y_1$, then they must be co-prime because $p$ is a prime. In this case, by Fermat little theorem, we have $$x_1^{p-1}\equiv y_1^{p-1}\equiv 1\pmod{p}$$
Setting this to the early result of $x_1^{p-1}\equiv y_1^{p-1}\equiv 1\pmod{p}$ will yield $1\equiv -1\pmod{p}$. This will force $p=2$ which contradicts to the assumption that $p$ is an odd prime. This means $p\equiv 1\pmod{4}$ has to be held.