Let $R$ be a commutative ring. If I am not mistaken, there is the following fact:



> 
> For a finitely generated abelian group $A$, the $R$-module $A\otimes R$ is free if and only if we can write the torsion part of $A$ as a direct sum of cyclic groups of the form $\mathbb{Z}/k$, where $k$ is invertible or zero in $R$ 
> 
> 
> 


While elementary, I found this surprisingly tricky to prove and my proof takes about half a page. But I assume, this fact should be known. As I need it for a paper of mine, I want to ask whether someone knows a reference for it. In absence of a reference, I would also be happy with a slick 5-line proof! 



When is $A\otimes R$ a free $R$-module?
Here is a 7-line proof of your statement.



> 
> 
> > 
> > **Claim.** Let $R$ be a commutative ring with identity $1\_R$. Let $A \simeq \mathbb{Z}/d\_1\mathbb{Z} \oplus \cdots \oplus \mathbb{Z}/d\_k\mathbb{Z}$ be a finitely generated Abelian group given with its invariant factor decomposition, i.e., $d\_i \ge 0, d\_i \neq 1$ and $d\_i$ divides $d\_{i + 1}$ for every $1 \le i \le k - 1$ (*note that $d\_i = 0$ is allowed*).
> > 
> > 
> > Then $A \otimes\_{\mathbb{Z}} R$ is free over $R$ if and only if either $d\_i 1\_R$ is zero or a unit of $R$ for every $i$.
> > 
> > 
> > *Proof (7 lines)*. Let $M \Doteq A \otimes\_{\mathbb{Z}} R \simeq 
> > R/d\_1 R \oplus \cdots \oplus R/d\_k R$. If $d\_i 1\_R$ is zero or a unit of $R$ for every $i$, then $M$ is clearly free over $R$. Assume now that $M$ is free over $R$. We reason by contradiction and consider the smallest $j \ge 1$ such that $d\_j 1\_R$ is neither zero nor a unit. Then we have $M \simeq R/d\_j R \oplus \cdots \oplus R/d\_k R$. Considering $M/\mathfrak{m}M$ for a maximal ideal $\mathfrak{m}$ which contains $d\_jR$, we see that the minimal number of generators of $M$ over $R$ is $s \Doteq k -j + 1$. Therefore $M \simeq R^s$ and consequently $d\_jM$ cannot be generated by less than $s$ elements. As $d\_jM \simeq 
> > (d\_jR/d\_{j + 1} R) \oplus \cdots \oplus (d\_jR/d\_k R)$, we get a contradiction.
> > 
> > 
> > 
> 
> 
> 


You may turn the above proof into a one-liner if you refer to this more general result of Irving Kaplansky [1, Theorem 9.3].



> 
> 
> > 
> > **Kaplansky's Theorem.** 
> >  Let $R$ be a ring in which every one-sided ideal is two-sided. In particular, $R$ may be any commutative ring. Suppose the $R$-module $M$ is isomorphic to the direct sum of cyclic modules $R/S\_1, \dots, R/S\_m$, and also to the direct sum of $R/T\_1, \dots, R/T\_n$, where $S\_i,\, T\_¡$ are ideals each containing its successor, $S\_1, T\_1\neq R$. Then $m = n$ and $S\_i = T\_i$ for all $i$.
> > 
> > 
> > 
> 
> 
> 




---


**Addendum.** I found the discussion of Qiaochu Yuan and YCor about projective modules (see comments above) particularly enlightening. This is why I would like to assemble all its fragments here.



> 
> 
> > 
> > **Qiaochu Yuan's Claim on projectives.** Let $R$ be a commutative ring with identity and let $A$ be a direct sum of cyclic groups $\mathbb{Z}/k\_i\mathbb{Z}$ where $k\_i \in \mathbb{Z}$ and $i$ ranges in some arbitrary set.
> >  Then $A \otimes\_{\mathbb{Z}} R$ is a projective module over $R$ if and only if $k\_iR = k\_i^2R$ for every $i$.
> > 
> > 
> > *Proof.* Let $M \Doteq A \otimes\_{\mathbb{Z}} R \simeq 
> > \bigoplus\_i R/k\_i R$. Then $M$ is projective over $R$ if and only if $R/k\_iR$ is projective for every $k$. This holds if and only if the natural map $R \twoheadrightarrow R/k\_iR$ splits for every $i$, which is in turn equivalent to the fact that $k\_iR$ is an idempotent ideal. As observed by YCor, $k\_iR$ is generated by an idempotent in this case, see e.g, [2, Exercise 2.1], a classical application of Nakayama's lemma.
> > 
> > 
> > 
> 
> 
> 


If $\mathbb{Z}1\_R \simeq \mathbb{Z}/n\mathbb{Z}$ for some $n > 1$, then 
the condition $\text{gdc}(k, n) = \text{gdc}(k^2, n)$, or equivalently $\text{gcd}(k, \frac{n}{\text{gcd}(n, k)}) = 1$, implies $kR = k^2R$. This is certainly a necessary condition when $R = \mathbb{Z}/n\mathbb{Z}$.


YCor outlined the fact that **every** module over $\mathbb{Z}/6\mathbb{Z}$ is projective. He further extends this remark by mentioning below that every module over a commutative ring $R$ with identity is projective if and only if $R$ is the direct product of finitely many fields, see this [MO post](https://mathoverflow.net/questions/62464/rings-with-all-modules-projective) for references and a more general statement. 



> 
> 
> > 
> > **Remark on projective modules over $\mathbb{Z}/n\mathbb{Z}$.** Let $n$ be a positive integer. Then the following are equivalent:
> > 
> > 
> > 
> 
> 
> * The integer $n$ has no square factor.
> * Every module over $\mathbb{Z}/n\mathbb{Z}$ is projective.
> 
> 
> 
> > 
> > *Proof*. By the [first Prüfer Theorem](https://en.wikipedia.org/wiki/Abelian_group), a module over $R = \mathbb{Z}/n\mathbb{Z}$ is a direct sum of cyclic factors $\mathbb{Z}/k\mathbb{Z}$ where $k$ divides $n$. If $n$ is square-free, any such factor is projective over $R$ by Qiaochu Yuan's Claim. Hence any module over $R$ is projective. If $n$ has a square factor $k^2$ with $k > 1$, then $R/kR$ is not projective over $R$ by Qiaochu Yuan's Claim.
> > 
> > 
> > 
> 
> 
> 




---


[1] I. Kaplansky, "Elementary divisors and modules", 1949.  

[2] H. Matsumura, "Commutative Ring Theory", 1986.


