Invertible or zero divisor in $\mathbb Z_n$ Is it true (for $n \le 10$) that every nonzero element in $\mathbb Z_n$ is either invertible or a zero divisor?
Can anyone please help me.
Thank you
 A: This is true in $\mathbb Z_n$ for every $n$.
Consider $a\neq 0$ and look at the set of products
$$
P = \left\{\ ab \ \big|\ b\in\mathbb Z_n, b\neq 0\ \right\}.
$$
If $0\in P$, then $a$ is a zero divisor. If $1\in P$ then $a$ is invertible.
If $0,1\notin P$ we have $|P|\le n-2$, since there are $(n-1)$ different $b\neq 0$, there must be $b\neq b'$ with $ab=ab'$, thus
$$
a(b-b') = ab-ab' = 0,
$$
so $a$ is again a zero divisor.
A: Let $a \in \mathbb Z_n$. Look at $f: \mathbb Z_n \to \mathbb Z_n$ $f(x)=ax$.
If $f$ is one to one, then, it must be onto and hence $f(b)=1$ for some $b$.
If $f$ is not one to one, you can find $b \neq c$ so that $f(b)=f(c)$. Thus
$$a(b-c) =0 \,.$$
A: Let $1 \le a < n$ and let $\mathrm{gcd}(a,n) = d$. By Bézout's identity there exist integers $x,y$ such that $ax+ny=d$.

*

*If $d=1$ then you have $ax \equiv 1 \pmod{n}$, so $a$ is invertible with inverse $x$.


*If $d>1$ then there exists $0<k<n$ such that $dk=n$, and then
$$a(xk) \equiv (ax+ny)k \equiv dk \equiv n \equiv 0 \pmod{n}$$
so $a$ is a zero divisor.
