Gaussian prime (source code)

= Gaussian prime
{c}

A <Gaussian prime> is a nonzero nonunit <Gaussian integer> irreducible in $\mathbb Z[i]$. Since this <ring> is a <Euclidean domain>, irreducible and prime elements coincide. For $a,b\ne0$, $a+bi$ is a <Gaussian prime> exactly when $a^2+b^2$ is an ordinary <prime number>. On a coordinate axis, it is prime exactly when the nonzero coordinate has absolute value an ordinary prime congruent to three modulo four.

Thus $1+i$, $2+i$, and $3$ are <Gaussian primes>, while $2=-i(1+i)^2$ and $5=(2+i)(2-i)$ are not. The multiplicative <norm> $N(a+bi)=a^2+b^2$ makes these factorizations and primality tests transparent.