Prove that $a+ib$ is prime in $\Bbb Z[i]$, if $a^2+b^2$ is prime in $\Bbb Z$.
My Try: We can easily show that $\Bbb Z[i]$ is a FD but how can we show that $\Bbb Z[i]$ is a UFD. Because if we can show that $\Bbb Z[i]$ is a UFD then we can use the fact that every irreducible element is prime...
The fact that $\Bbb Z[i]$ is a UFD follows from the stronger fact that it is an Euclidean domain. Note that given any complex number $z$, we can find $w=a+ib\in\Bbb Z[i]$ such that $|z-w|^2 \leqslant \frac{1}{2}$. You can prove this by dividing the complex plane into the grid determined by $\Bbb Z[i]$. Then $z$ must fall inside (or on) some square with integer coordinates and area $1$. If you subdivide this into four smaller squares, they have diagonal $\sqrt{1/2}$, hence $z$ is at most this distance away from the corner which has integer coordinates. Squaring gives the result.
Using the above suppose you have $w,z$ two elements of $\Bbb Z[i]$ (two Gaussian integers) which we can assume are nonzero. Then we know there is a Gaussian integer $q$ with $|wz^{-1}-q|^2\leqslant \frac 1 2 $, which gives $|w-zq|^2\leqslant |z|^2/2<|z|^2$.
Call $r=w-zq$, then note we can write $w=qz+r$, and $Nr<Nz$ as we wanted, i.e. we have proven that given $w,z$ Gaussian integers there are a Gaussian integers $q,r$ such that $w=qz+r$ and $Nr<Nz$. This is precisely the statement that $\Bbb Z[i]$ is Euclidean with the norm $Nz=|z|^2$.
Alternatively, note $\Bbb Z[i]$ as a $\Bbb Z$-module is free with basis $1,i$, and the ideal generated by $w=a+ib$ is generated by $a+ib,-b+ia$ as a $\Bbb Z$-module. The matrix for this generators is $A=\begin{pmatrix}a&-b\\b&a\end{pmatrix}$. Then $\det A = a^2+b^2$, so if we carry this to its normal form it will have two nonzero invariant factors. Hence $\Bbb Z[i]/(w)$ will have $a^2+b^2=p$ elements. This means the quotient ring is no other than $\Bbb Z/p\Bbb Z$, hence the ideal $(w)$ is maximal.