After reading the question , I wondered which rings $A$ have the property that every element in $A$ is a unit or is a zero-divisor.
1) If the zero ideal has a primary decomposition (which is always the case for a noetherian ring), then the set of zero divisors is the union of the associated primes of the ring: $zdiv(A)=\bigcup _{{\mathfrak p}\in Ass(A)}\mathfrak p$ so that the condition for the property is that every maximal ideal of $A$ be an assassin.
This holds for all artinian rings (e.g. the ring $\mathbb Z/n\mathbb Z$ of the question ), but also for higher dimensional rings, like the one-dimensional localization $A=R_{\mathfrak m}$ of the notorious ring $R=k[X,Y]/(X^2, XY)=k[x,y]\quad (k \text { a field})$ at the maximal ideal $\mathfrak m=(x,y)$.
Notice that a primary decomposition of $(0)$ is $(0)=(x)\cap {\mathfrak m}^2$ and that $Spec (A)=Ass(A)=\lbrace\mathfrak m,(x)\rbrace$, so that $zdiv(A)=\mathfrak m$ .
2) Some non-noetherian rings also have the property that every non-unit is a zero-divisor.
Class of examples: rings with only one prime ideal, like the non-noetherian $$A=k[X_1, X_2,...,X_n,...]/(X_1^2,..., X_n^2,...) $$
WARNING Needless to say, this post is absurdly highbrow with respect to the actual question.
As Gadi remarks, the answer to Jose's question is to be found in fairly elementary algebra or number theory books.
I just wanted to address a more general question which might (or might not!) be of interest to more advanced users of our site.