Let $A$ be a commutative ring, and $X=\mathrm{Spec}\,A$ with its Zariski topology. I am asked to show that $X$ is not irreducible (i.e. $X=U\cup V$ with $U$ and $V$ two proper closed subsets) if and only if there exists two elements $f,g\in A$ non nilpotent such that $fg=0$.
The first part is easy: given such $f,g$, I simply take $U=V((f))=\{p\in X\,;\,(f)\subset p\}$ and $V=V((g))$, and I remark that $V((f))\cup V((g))=V((f)(g))=V((0))=X$. Since $f,g\neq 0$, $U$ and $V$ are indeed proper subsets (I do not use that $f,g$ are non nilpotent, but only they are non zero).
For the converse, if $X=U\cup V=V(I)\cup V(J)=V(IJ)$ with $I$ and $J$ proper and non zero ideals, I have that $IJ\subset (0)$ and then $IJ=(0)$.
My question is: is finding such elements $f,g$ would characterize that a such ideal product is zero? If yes, any hint about how can I prove it? Thank you for your attention.!