Number of distinct equivalence classes of $\mathbb Z_n$ of the " associate " equivalence relation Define an equivalence relation on $\mathbb Z_n$ as follows:
For $a,b \in \mathbb Z_n $, $a\sim b$ iff $\exists k \in U_n=\mathbb Z_n^{\times}$ such that $a=kb$ (i.e. $a,b$ are related if they are "associates", i.e. if one is unit multiple of another). 
My question is: 

How many distinct equivalence classes does this relation has ? 

 A: Let $R$ be a commutative unitary ring with the following property. For all $r\in R$ the quotient morphism on multiplicative groups $R^\times\rightarrow (R/\mathrm{Ann}(r))^\times$ is surjective. Recall that for $r\in R$, the annihilator $\mathrm{Ann}(r)$ of $r$ is the ideal in $R$ consisting of all $s\in R$ with $sr=0$. Recall also that the ideal $(r)$ generated by $r$ is isomorphic to the $R$-module $R/\mathrm{Ann(r)}$.
Under the above condition on $R$, there is a a bijection between the set of elements of a ring $R$ up to units and the set $\Pi$ of principal ideals of the ring $R$. The set of elements of $R$ up to units is the quotient set $R/\sim$, where $\sim$ is the equivalence relation of being associated. The bijection is the map
$$
\phi\colon R/\sim\rightarrow \Pi
$$
that maps an element $r$ to the ideal of $R$ generated by $r$. Of course, this map is well-defined and surjective. In order to prove injectivity, suppose that $\phi(r)=\phi(s)$, i.e., $r$ and $s$ generate the same ideal in $R$. Then, there is $a\in R$ such that $s=ar$. Then $a(r)=(ar)=(r)$. Hence
$aR/\mathrm{Ann}(r)=R/\mathrm{Ann}(r)$. It follows that $a$ is invertible in the ring $R/\mathrm{Ann}(r)$. By hypothesis, there is $n\in\mathrm{Ann}(r)$ such that $a+n$ is invertible in $R$. Then $(a+n)r=ar+nr=ar+0=s$, so that $r$ and $s$ are associated.
The ring $\mathbf Z/n$ satisfies the above property. Indeed, any quotient ring of $\mathbf Z/n$ is of the form $\mathbf Z/m$, for some divisor $m$ of $n$. Write $n=n'm'$ with $\gcd(n',m)=1$, and $m$ and $m'$ having the same prime divisors. Let $k\in\mathbf Z$ be relatively prime with $m$. Since $n'$ and $m'$ are relatively prime, there is a $k'\in \mathbf Z$ such that $k'\equiv1\bmod n'$ and $k'\equiv k\bmod m'$ by the Chinese remainder theorem. Since $k$ is relatively prime with $m$, it is also relatively prime with $m'$. Since $k'\equiv k\bmod m'$, the integer $k'$ is relatively prime with $m'$ as well. Since $k'\equiv1\bmod n'$, the integer $k'$ is also relatively prime with $n'$. It follows that $k'$ is relatively prime with $n'm'=n$. Since $m|m'$, one has $k'\equiv k\bmod m$. This proves that the map $(\mathbf Z/n)^\times\rightarrow (\mathbf Z/m)^\times$ is surjective for all divisors $m$ of $n$. In particular, the ring $\mathbf Z/n$ satisfies the property above.
As a consequence, the number of elements of the quotient set $(\mathbf Z/n)/\sim$ is equal to the number of principal ideals of $\mathbf Z/n$. Now, one knows that the subgroups of $\mathbf Z/n$ are of the form $d\mathbf Z/n$, i.e., the subgroup generated by $d$, for a uniquely defined  positive divisor $d$ of $n$. Note that all these subgroups are automatically principal ideals of $\mathbf Z/n$. It follows that the number of elements of the quotient set $(\mathbf Z/n)/\sim$ is equal to the number of divisors of $n$.
