Recently, I learnt this nice theorem of Kaplansky:
Let $R$ be an integral domain. Then $R$ is a UFD iff every nonzero prime ideal contains a nonzero prime principal ideal.
Using this theorem, it follows easily that all PIDs are UFDs.
Now let $R$ be an integral domain such that every ideal $I$ in $R$ is of the form $(a,b)$ for some $a,b\in R$. Is there a necessary and sufficient condition about when the ring $R$ is a UFD ? In other words, is there a good way to characterize which rings like $R$ are UFDs ?