Does there exist a UFD (which is not a field) having only finitely many irreducible elements?
Definition of a UFD is: $R$ is an integral domain ($R$ is a commutative ring having unity and no zero-divisors) such that each $a\in R \setminus (R^* \cup {0})$ factors into a product of irreducible elements.
I've tried to look for one, but without luck so far.
Best Answer
If you localize $\mathbb Z$ at the multiplicative set $S=\mathbb Z-\bigcup_{i=1}^n p_i\mathbb Z$, where $p_i$ are distinct primes, then you get a UFD having exactly $n$ prime elements.
Edit. (To answer some questions raised in the comments.)
Say $q_1,\dots,q_m$ are all primes. Set $a=q_1\cdots q_m$ and consider $a+1,a^2+1,\dots$. Since all these elements are invertible there exist $i\ne j$ such that $a^i=a^j$, a contradiction.
As a side note, a UFD having finitely many primes is necessarily a PID.