Let p be prime with $\displaystyle p \equiv 1 (mod \ 4) $ Show that there are integers a,b for which $\displaystyle p=a^2 + b^2 $
(This is Fermat's theorem. The elementary version (Fermat's) is much more difficult. It is amazing how simple arguments on unique factorization make theorems like this so simple).
By the other arguments $\displaystyle p$ is not irreducible. Thus, there exists $\displaystyle a,b,c,d\in \mathbb{Z}$ such that $\displaystyle p = (a+bi)(c+di)$ take the norm of both sides to get $\displaystyle p^2 = (a^2+b^2)(c^2+d^2)$. Now work with unique factorization over $\displaystyle \mathbb{Z}$. It cannot be that one of those factors is $\displaystyle 1$ and the other $\displaystyle p^2$ because we cannot write $\displaystyle 1=a^2+b^2$ if $\displaystyle a,b\not = 0$. Thus, it means $\displaystyle p=a^2+b^2=c^2+d^2$. (In fact, $\displaystyle a^2+b^2$, and $\displaystyle c^2+d^2$ are exactly the same, i.e. there is also uniqueness involved but that is a different story).