Is there any way to count the prime elements in a ring?
More precisely a way to count prime elements in a UFD? Which would be the same as counting irreducibles. Are there even UFD with finitely many prime elements?
For $\mathbb{Z} / n\mathbb{Z}$ if $n$ is a prime in $\mathbb{Z}$ it is a field and there are no prime elements. If $n$ is not a prime all $p\mathbb{Z}/n\mathbb{Z}$ where $p$ occurs in the prime factorization is a prime in $\mathbb{Z} / n\mathbb{Z}$. Is that correct? This would imply that there are rings with any number of prime elements. For the case $\mathbb{Z} / n\mathbb{Z}$ they are not a UFD. But are there any other UFD I don't know about yet?
You essentially want to count the number of prime principal ideals of the ring. I don't think there's a universal way to count without knowing about the ring structure.
Yes, for example, $k[[x]]$ is a PID with only one irreducible/prime element: $x$.
We could handle the case of finite rings specially, since prime ideals are necessarily maximal. You're also guaranteed there are only finitely many maximal ideals. So in this case, I'd first list the maximal ideals and then check which ones were principal. Then you'd have your list of primes.
$\mathbb Z/n\mathbb Z$ is easy because it is a finite principal ideal ring. You don't have to decide which maximal ideals are principal because they ALL are principal. The maximal ideals correspond to the primes which divide $n$ (and aren't equal to $n$), so there will be exactly that many primes. In the case of $p$, there are zero such primes dividing $p$.