Method to generate counterexample: An irreducible that is not prime. I am a newcomer in ring theory.I like the method of studying by myself with as less help from the textbook as possible.I prove the theorems on my own and always look for counterexamples if the converse of a statement does not hold.Now while studying irreducibilty in integral domain,I came up with the result that primes are irreducibles but irreducibles may not be prime.
Every student of ring theory would probably know the counterexample ,which is a very standard one: $\mathbb Z[\sqrt{-5}]$ and the element $2$.It is easy for one to verify that it is irreducible but not prime.
But my question is something different.If one does not know such kind of examples beforehand,then it is not easy for him/her to construct such example.How will one know that $\mathbb Z[\sqrt {-5}]$ would work?And suppose one makes a guess to work with such a ring,how would one know beforehand what kind of element to select so that it satisfies our requirement.There is no way other that searching randomly,if you are lucky you will find one.I have seen all books just citing counterexamples,but none of them explains the thought process behind the counterexample i.e. how to generate a family of such counterexamples or how reach such example without giving a random try.
So,does anyone have any thought process in mind so that I can find such counterexamples on my own.I am not looking for some formula for such rings.I am looking for the thought behind such counterexample.
 A: "How will one know that $\Bbb Z[\sqrt{-5}]$ would work?"
The idea is to look at integral domains which are not PIDs.
It is natural to consider first the rings of integers in quadratic number fields $\Bbb Q(\sqrt{m})$ for square-free integers $m$. These rings are factorial if and only if they are PIDs. 
In particular for $m<0$ it is well known which of such rings are PIDs, i.e., exactly when
$$m= −1, −2, −3, −7, −11, −19, −43, −67, −163$$
see
For which values of $d<0$ , is the subring of quadratic integers of $\mathbb Q[\sqrt{d}]$ is a PID?
So for counterexamples we would look at square-free $m<0$ with $m\equiv 2,3 \bmod 4$ different from the above list.
A: For sake of simplicity, I will stick to the case of  $R=\mathbb{Z}[\sqrt{-d}]$ where $d\geq 2$ is squarefree.
Let $p$ be a prime number such that $-d$ is a square modulo $d$ (you can check that $-d$ is a square mod $p$ or not algorithmically using the Jacobi symbol). Let $a\in\mathbb{Z}$  such that $a^2\equiv -d \mod p$.
Then $p\mid a^2+db^2=(a+\sqrt{d})(a-\sqrt{-d})$, but $p\nmid a\pm \sqrt{-d}$ since $p\nmid \pm 1$ in $\mathbb{Z}$. Hence $(p)$ is not a prime ideal and $p$ is not prime.
Now if $p$ is small enough, it will be irreducible. For example if $p<d$, it will be irreducible.
Indeed, assume that $p=z_1z_2$, $z_i\in R$. Then $p^2=\vert z_1\vert^2 \vert z_2\vert^2$, so $\vert z_1\vert^2=1,p,p^2$.
If $\vert z_1\vert^2=1$, one may show that $z_1=\pm 1$ so it is a unit (this will use $d\geq 2$). If $\vert z_1\vert^2=p^2$, then $\vert z_2\vert^2=1$, and $z_2=\pm 1$ so it is a unit. 
If $z_1=u+v\sqrt{-d}$ and $\vert z_1\vert^2=p$, then $u^2+dv^2=p$. Since $p<d$, $v=0$, so $p=u^2$, a contradiction. 
Note that, more generally, $p$ will be irreducible if $u^2+dv^2=p$ has no solutions.
