Why is $\mathbb{Z}[\sqrt{-n}], n\ge 3$ not a UFD?

If $n$ is even, then $2$ divides $\sqrt{-n}^2=-n$ but does not divide $\sqrt{-n}$, so $2$ is a nonprime irreducible. In a UFD, all irreducibles are prime, so this shows $\mathbb{Z}[\sqrt{-n}]$ is not a UFD.

Similarly, if $n$ is odd, then $2$ divides $(1+\sqrt{-n})(1-\sqrt{-n})=1+n$ without dividing either of the factors, so again $2$ is a nonprime irreducible.

This argument works equally well for $n=3$, but fails for $n=1,2$, and in fact $\mathbb{Z}[\sqrt{-1}]$ and $\mathbb{Z}[\sqrt{-2}]$ are UFDs.


It really depends on what $-n$ is, but if you have to guess for a random $n$, it's a safe bet to say it's not a UFD, because only nine of the imaginary quadratic rings are UFDs. The general principle is to find an example of a number with two distinct factorizations, thereby proving the domain is not a unique factorization domain.

The norm function is of crucial importance. I've seen the norm function normally defined as $N(a + b \sqrt{-n}) = a^2 + nb^2$. It's also important to note that $N(a + b \sqrt{-n}) = (a - b \sqrt{-n})(a + b \sqrt{-n})$. This means that if $m$ is an integer without an imaginary part, and prime in $\mathbb{Z}$, then it's irreducible if there's no way to express it as $a^2 + nb^2$. From this it follows that those real integers from $2$ to $n - 1$ which are prime in $\mathbb{Z}$ are therefore irreducible in $\mathbb{Z}[\sqrt{-n}]$. These are called "inert primes;" there are other inert primes, of course, but for those you have to check norms to be sure.

If $n = 2k$ and $k > 1$ is a squarefree real integer, it automatically follows that $\mathbb{Z}[\sqrt{-n}]$ is not a UFD because $n = (-1)(\sqrt{-n})^2 = 2k$. The latter factorization is further reducible if $k$ is composite in $\mathbb{Z}$, but it still represents a second factorization, distinct from the former, and therefore $\mathbb{Z}[\sqrt{-n}]$ is not a UFD.

For example, $10$ in $\mathbb{Z}[\sqrt{-10}]$. $2$ and $5$ are irreducible in this domain, as is $\sqrt{-10}$. Then we have $10 = (-1)(\sqrt{-10})^2 = 2 \times 5$. Since $10$ has two distinct factorizations in $\mathbb{Z}[\sqrt{-10}]$, that domain is not a UFD.

If $n = 2k - 1$ squarefree, we just need to show that $2k = (1 - \sqrt{-n})(1 + \sqrt{-n})$ and we're done. That is, unless $n \equiv 3 \bmod 4$. Because in that case $\mathbb{Z}[\sqrt{-n}]$ is not "integrally closed." Then we have to consider not just numbers of the form $a + b \sqrt{-n}$, but we also have to look at numbers of the form $\frac{a}{2} + \frac{b \sqrt{-n}}{2}$, where both $a$ and $b$ are odd. These numbers are sometimes called "half-integers" purely for convenience. The norm function is then $N\left(\frac{a}{2} + \frac{b \sqrt{-n}}{2}\right) = \frac{a^2}{4} + \frac{nb^2}{4}$, and it gives real integers as results. Then we have to see if maybe $\frac{n + 1}{4}$ is composite and has two distinct factorizations, or if it is prime then we look to see if there's another real integer of the form $\frac{a^2}{4} + \frac{nb^2}{4}$ with two distinct factorizations in the domain at hand.

For example, in $\mathbb{Z}\left[\frac{1}{2} + \frac{\sqrt{-15}}{2}\right]$ (which we can also notate as $\mathcal{O}_{\mathbb{Q}(\sqrt{-15})}$ if we want), $2$ is irreducible, as is $\frac{1}{2} \pm \frac{\sqrt{-15}}{2}$. Then we have $4 = \left(\frac{1}{2} - \frac{\sqrt{-15}}{2}\right)\left(\frac{1}{2} + \frac{\sqrt{-15}}{2}\right) = 2^2$.

It's a little trickier in $\mathcal{O}_{\mathbb{Q}(\sqrt{-51})}$, since $\frac{51 + 1}{4} = 13$, which is prime in $\mathbb{Z}$. So we look instead to $15 = \left(\frac{3}{2} - \frac{\sqrt{-51}}{2}\right)\left(\frac{3}{2} + \frac{\sqrt{-51}}{2}\right)$. This is a distinct factorization from $3 \times 5$ because $3$ and $5$ are irreducible in this domain.

There are only seven values of $n \equiv 3 \bmod 4$ such that $\mathcal{O}_{\mathbb{Q}(\sqrt{-n})}$ is a UFD: $3, 7, 11, 19, 43, 67, 163$. Together with $1$ and $2$, these are the nine values of $n$ corresponding to imaginary quadratic rings with unique factorization. Carl Friedrich Gauss knew these numbers, but Heegner and Stark are the ones who proved there are no others. (Real quadratic rings, that's a different story).

I have to admit I'm still a novice at this subject, for up to a few months ago I was quite unaware of the existence of $\sqrt{-1}$ and I still find the concept somewhat unreal and hard to believe, no pun intended. I may have made some tiny mistakes which others will greatly magnify.