Let $R$ be an integral domain. We say that an element $r\in R$ is a unit if it is invertible. A non-unit is called irreducible if it can not be represented as a product of two non-units.
A commutative integral domain $R$ is a unique factorization domain (UFD for short) if every non-unit has a factorization $u = r_1 \cdots r_n$ as product of irreducible non-units and this decomposition is unique up to renumbering and rescaling the irreducibles by units.
Put differently: $R$ is a UFD precisely when the multiplicative monoid of nonzero principal ideals of $R$ (which is isomorphic to the monoid $(R \setminus \{0\})/R^\times$, where $R^\times$ denotes the group of units) is a commutative monoid freely generated by irreducible principal ideals. It follows that if $K$ is the field of fractions of $R$, then the quotient group $K^\times/R^\times$ is an abelian group that is freely generated by the set of cosets $f R^\times$ with $f$ ranging over irreducible elements. As a side remark, we observe that in this circumstance the exact sequence
splits and there is an isomorphism $K^\times \cong R^\times \oplus (K^\times/R^\times)$ of abelian groups.
The ring of (rational) integers $\mathbb{Z}$ is a UFD.
A principal ideal domain (PID) is a UFD. (In particular, a Euclidean domain is a UFD.) As a partial converse, a Dedekind domain that is a UFD is a PID.
If $R$ is a UFD, then its polynomial ring $R[x]$ is also a UFD.
If $R$ is a UFD, then so is any localization $S^{-1} R$.
A regular local ring (for example, a discrete valuation ring) is a UFD.
If $R$ is a UFD and all of its localizations at primes are regular local rings, then the ring of formal power series $R[ [x] ]$ is a UFD.
For $D$ a positive integer, the ring of integers in $\mathbb{Q}(\sqrt{-D})$ is a UFD iff $D$ is a Heegner number, namely one of the numbers $1, 2, 3, 7, 11, 19, 43, 67, 163$.
If $R$ is not integrally closed, then it is not a UFD.
As noted above, a UFD is necessarily integrally closed.
The lattice of principal ideals under the inclusion order is a distributive lattice.