Take $R$ to be the ring of polynomials in which the $x$ term does not appear, i.e. polynomials of the form $$a_0+a_2x^2+...$$ Then by induction on the degree we have that $R$ is an atomic domain, since every element is prime or product of two polynomials with less degree. And if we take the polynomial $$x^6$$ we have that $$x^2\cdot x^2 \cdot x^2$$ and $$x^3\cdot x^3$$ have different length as desired. (One can easily prove that $x^2$ and $x^3$ are prime in $R$.)


By a classic result of Carlitz, a number ring is a half-factorial domain iff it has class number $1$ or $2$. In particular this is true for $\:\mathbb Z[\sqrt{-5}]\:.\:$ For a proof see Coykendall, Half-factorial domains, a survey.

For a very simple example of a non-HFD consider $\rm\: x\: =\: 2^n\: (x/2^n) \in \mathbb Z + x\ \mathbb Q[x]\:.\:$ More generally it is easy to show that if $\rm\:R\:$ is a subring of a field $\rm\:K\:$ then $\rm\:R + x\ K[x]\:$ is an HFD $\rm\iff\:R\:$ is a field.

Note also that if a domain is not a UFD then it has an equal-length non-unique factorization , see Coykendall and Smith, Unique factorization domains.


The ring of integers of any number field will have the property that elements factor as a finite product of irreducibles. To see this, let $R$ be such a ring of integers and $x$ a nonzero, noninvertible element of $R.$ Then, as $R$ is noetherian, we may choose an ideal maximal among the principal ideals containing $x.$ Any generator of this ideal is irreducible. Let $u_0$ be such a generator. It follows that the ideal $(x)$ factors $(u_0)I$ for some nonzero ideal $I.$ Considering the image of these ideals in the class group of $R,$ we obtain $I$ is principal generated by some element $x_1.$ But the prime factorization of the ideal $(x_1)$ is finite and shorter than the prime factorization of the ideal $(x).$ Thus by an inductive argument, we obtain that every element of $R$ factors as the product of irreducibles.

Two factorizations of any element will have the same length if and only $R$ has class number 1 or 2. This answers your question about $\mathbb{Z}[\sqrt{-5}].$