# Thread: Prime problem

1. ## Prime problem

Let p be prime with $p \equiv 1 (mod \ 4)$ Show that there are integers a,b for which $p=a^2 + b^2$

2. Originally Posted by tttcomrader
Let p be prime with $p \equiv 1 (mod \ 4)$ Show that there are integers a,b for which $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 $p$ is not irreducible. Thus, there exists $a,b,c,d\in \mathbb{Z}$ such that $p = (a+bi)(c+di)$ take the norm of both sides to get $p^2 = (a^2+b^2)(c^2+d^2)$. Now work with unique factorization over $\mathbb{Z}$. It cannot be that one of those factors is $1$ and the other $p^2$ because we cannot write $1=a^2+b^2$ if $a,b\not = 0$. Thus, it means $p=a^2+b^2=c^2+d^2$. (In fact, $a^2+b^2$, and $c^2+d^2$ are exactly the same, i.e. there is also uniqueness involved but that is a different story).