TITLE: Why over $\mathbb{Z}/n\mathbb{Z}$ projectivity, injectivity and flatness coincide for cyclic modules?
QUESTION [9 upvotes]: Assume $R=\mathbb{Z}/n\mathbb{Z}$ ($n\neq0$) and let $M$ be a cyclic $R$-module. Could you tell me how to prove that $M$ is projective if and only if it is injective if and only if it is flat? And also why $M$ is free if and only if it is cofree?
By cardinality reasons I think I proved that if $M$ is free then it is equal to $R$, but I don't get the rest.

REPLY [4 votes]: Let me expand on the comment I made (the other answer is great, by the way. But, I did have fun working it all out by hand).
First, since $M$ is cyclic it is of the form $\mathbb{Z}/m\mathbb{Z}$ for some $m \mid n$ and $m > 1$. I claim that $M$ is projective (resp. flat, injective) if and only if $(m,n/m) = 1$.
Suppose that $m\mid n$ and $m'\mid n$. The key is the knowledge of $(*)$:
\begin{equation*}
\operatorname{Hom}_{\mathbb{Z}/n\mathbb{Z}}(\mathbb{Z}/m'\mathbb{Z}, \mathbb{Z}/m\mathbb{Z}) \simeq \mathbb{Z}/\operatorname{gcd}(m,m')\mathbb{Z} \simeq \mathbb{Z}/m\mathbb{Z} \otimes_{\mathbb{Z}/n\mathbb{Z}} \mathbb{Z}/m'\mathbb{Z}.
\end{equation*}
Neither of these are so hard, so I'll leave it to you.
Now, consider the short exact sequence $(**)$:
\begin{equation}
0 \rightarrow \mathbb{Z}/(n/m)\mathbb{Z} \rightarrow \mathbb{Z}/n\mathbb{Z} \rightarrow \mathbb{Z}/m\mathbb{Z} \rightarrow 0.
\end{equation}
Let $d = \gcd(n/m,m)$. Here are some of the proofs.
Projective, resp. injective, resp. flat implies $d=1$: Take $\operatorname{Hom}_{\mathbb{Z}/n\mathbb{Z}}(\mathbb{Z}/m\mathbb{Z},-)$, resp. $\operatorname{Hom}_{\mathbb{Z}/n\mathbb{Z}}(-,\mathbb{Z}/m\mathbb{Z})$, resp. $-\otimes_{\mathbb{Z}/n\mathbb{Z}} \mathbb{Z}/m\mathbb{Z}$ of the sequence (**) and using the "key fact'' $(*)$ I gave.
$d = 1$ implies projective: $\mathbb{Z}/m\mathbb{Z}$ is a direct summand of $\mathbb{Z}/n\mathbb{Z}$ by the Chinese remainder theorem: $$\mathbb{Z}/n\mathbb{Z} \simeq \mathbb{Z}/m\mathbb{Z} \oplus \mathbb{Z}/(n/m)\mathbb{Z}.$$
$d=1$ implies flat: projective things are flat and $d = 1$ implies projective.
$d = 1$ implies injective: This one was the trickiest one (for me). By Baer's criterion it is enough to show that the natural map
\begin{equation*}
\mathbb{Z}/m\mathbb{Z} \simeq \operatorname{Hom}_{\mathbb{Z}/n\mathbb{Z}}(\mathbb{Z}/n\mathbb{Z},\mathbb{Z}/m\mathbb{Z}) \rightarrow \operatorname{Hom}_{\mathbb{Z}/n\mathbb{Z}}(\mathbb{Z}/k\mathbb{Z},\mathbb{Z}/m\mathbb{Z}) \simeq \mathbb{Z}/\gcd(k,m)\mathbb{Z}
\end{equation*}
is surjective for every $k\mid n$ (the groups $\mathbb{Z}/k\mathbb{Z}$ are all the possible ideals inside $\mathbb{Z}/n\mathbb{Z}$). Note that the inclusion $\mathbb{Z}/k\mathbb{Z} \hookrightarrow \mathbb{Z}/n\mathbb{Z}$ is given by $x \mapsto (n/k)x$. Thus, if you stare at this long enough you will see that the composition $(***)$
\begin{equation*}
\mathbb{Z}/m\mathbb{Z} \rightarrow \mathbb{Z}/\gcd(k,m)\mathbb{Z}
\end{equation*}
is given by $x \mapsto {n \over mk'}x$ where $k = \gcd(k,m)k'$. Since $k'$ is invertible modulo $m$ (by definition), the map $(***)$ is surjective if and only if $n/m$ is invertible module $\gcd(k,m)$. Since $\gcd(n/m,m) = 1$, this is clearly true. Indeed, $\gcd(k,m)\mid m$ and so $\gcd(n/m,\gcd(k,m)) = 1$.