TITLE: The ring $ℤ/nℤ$ is a field if and only if $n$ is prime
QUESTION [27 upvotes]: Let $n \in ℕ$. Show that the ring $ℤ/nℤ$ is a field if and only if $n$
  is prime.

Let $n$ prime. I need to show that if $\bar{a} \neq 0$ then $∃\bar b: \bar{a} \cdot \bar{b} = \bar{1}$. Any hints for this ?
Suppose $ℤ/nℤ$ is a field. Therefore: for every $\bar{a} \neq 0$ $∃\bar b: \bar{a}\cdot \bar{b}=1$. How can I show that $n$ must be prime ?

REPLY [29 votes]: If $n$ is prime and $\overline a\ne0$ so $a$ isn't a multiple of $n$ and then $a$ and $n$ are coprime so by the Bezout theorem there's $b,c\in\mathbb Z$ such that
$$ba+cn=1$$
hence by passing to the class we find $\overline a\overline b=\overline1$.
Conversely if $n$ isn't prime then we write $n=ab$ so $\overline0=\overline a\overline b$ where $\overline a\neq \overline0 $ and $\overline b\neq 0$ hence $\mathbb Z/n\mathbb Z$ isn't an integral domain and then it isn't a field.