Number of distinct associated classes of the ring $\mathbb{Z}_n[i]$. Let $x, y$ be two elements of a commutative ring $R$.
Then we say $x$ and $y$ are associate, denoted $x ∼ y$, if and only if  $x = uy$ for a unit $u$ in $R$.
Then the equivalence class, $[x] = \{z \in R| z ∼ x\}$ is the associate class of $x$.
My question is: How many different associated classes exist in the ring of Gaussian integers modulo $n$?, $\mathbb{Z}_n[i]$. I expect an answer in terms of $n$ or using the prime factorization of $n$ in $\mathbb{Z}[i]$ or in $\mathbb{Z}$.
I have seen the post about $\mathbb{Z}_n$. But, here unlike in $\mathbb{Z}_n$, the number of associated classes is not equal to the number of principal ideals. $\mathbb{Z}_4[i]$ is an example for this, which has 9 principal ideals but has only 5 associate classes.
Working out with examples for $n$ up to 12, I have noticed that,
If $n=2^ap_1^{k_1}p_2^{k_2}\cdots p_t^{k_t}q_1^{m_1}q_2^{m_2} \cdots q_s^{m_s}$ be the prime factorization of $n$ in $\mathbb{Z}$ such that $p_i\equiv 1 
\mod 4$ and $q_i \equiv  3 \mod 4$.
Then the number of conjugate classes is equal to $(2a+1)(K_1+1)^2(k_2+1)^2 \cdots (k_t+1)^2(m_1+1)(m_2+1)\cdots (m_s+1)$.
But I didn't found a way to prove this.
 A: It is also true here that the number of distinct associated classes of $\Bbb Z_n[i]$ is the number of principal ideals. You can run over the exact same argument, as the one in your linked post, to show that the map $$\chi:\left(\frac{\Bbb Z[i]}{(n)}\right)^\times\twoheadrightarrow \left(\frac{\Bbb Z[i]}{(\alpha)}\right)^\times$$
is surjective for any divisor $\alpha\in\Bbb Z[i]$ of $n$. To show this, let $\delta\in\left(\frac{\Bbb Z[i]}{(\alpha)}\right)^\times$, we want to construct a $\gamma\in\left(\frac{\Bbb Z[i]}{(n)}\right)^\times$ such that $\chi(\gamma)=\delta$. Write $n=n'\alpha'$, where $\gcd(n',\alpha')=1$ and let $\alpha'$ consist of the same primes as $\alpha$, therefore $\alpha\mid\alpha'$. Then by Bezout's identity (which holds in any PID) there are $x,y\in\Bbb Z[i]$ such that $$n'x+\alpha'y=1$$ Now let $\gamma=\delta n'x+\alpha' y$, then $\gcd(\gamma,n)=1$, so that $\gamma\in \left(\frac{\Bbb Z[i]}{(n)}\right)^\times$. Also $\chi(\gamma)=\delta$.

Looking at the factorization $n=2^ap_1^{k_1}p_2^{k_2}\cdots p_t^{k_t}q_1^{m_1}q_2^{m_2} \cdots q_s^{m_s}$ notice that:

*

*$p_i=\pi_i\bar\pi_i$, when $p\equiv_4 1$, and these $\pi_i,\bar\pi_i$ are non-associate primes. That is, $p_i$ is no longer a prime in $\Bbb Z[i]$.


Let $p$ be an odd prime, then $p=a^2+b^2$ for $a,b\in\Bbb Z\iff p\equiv_4 1$. This means that we can factor such primes as $p=(a+bi)(a-bi)$ in $\Bbb Z[i]$.
Proof:

*

*($\Rightarrow$) Suppose that $p=a^2+b^2$ is an odd prime, and consider $p\equiv_4 a^2+b^2$. The squares in $\Bbb Z_4$ are $0,1$, so we have that $p\equiv_4 0$, $p\equiv_4 1$ or $p\equiv_4 2$. The first and last congruence is impossible, since it would imply $p$ is even, so we must have $p\equiv_4 1$.


*($\Leftarrow$) Suppose that $p\equiv_4 1$, then we have $p\mid x^2+1$, by Fermats little theorem. Over $\Bbb Z[i]$ we have $x^2+1=(x+i)(x-i)$, but $p$ divides neither of these factors. Therefore $p$ is not a prime, and therefore let $p=\alpha\beta$ with $\alpha,\beta\in\Bbb Z[i]$. Taking the norm we have $p^2=N(p)=N(\alpha)N(\beta)$, since neither $\alpha,\beta$ are units we have $N(\alpha),N(\beta)>1$, therefore $N(\alpha)=N(\beta)=p$, so that $p=a^2+b^2$.


*

*$q_i$ is prime when $p\equiv_4 3$

*$2=i(1-i)^2$. But in this case notice that $(1+i)=i(1-i)$, so the ideals $(1+i), (1-i)$ are equal.

It is therefore easier to see your result if we rewrite the factorization of $n$ as
$$n=(1-i)^{2a}(\pi^{k_1}_1\bar{\pi}^{k_1}_1)(\pi^{k_2}_2\bar{\pi}^{k_2}_2)\cdots (\pi^{k_t}_t\bar{\pi}^{k_t}_t)q_1^{m_1}q_2^{m_2} \cdots q_s^{m_s}$$
This means that:

*

*$p^{k_i}_i$ gives ideals $(\pi^{x}_i\bar\pi^{y}_i)$ where $0\leq x,y\leq k_i$ so there are $(k_i+1)^2$ different ideals, because $p^{k_i}_i=\pi^{k_i}_i\bar\pi^{k_i}_i$ has $(k_i+1)^2$ divisors.


*$q^{m_i}_i$ is prime, so it has $m_i+1$ different divisors.


*$2^a=(i(1-i)^2)=i^a(1-i)^{2a}$. Here $(1-i)$ is irreducible so the number of divisors is $2a+1$.

The ring $\Bbb Z_4[i]$ has both 5 distinct principal ideals, and 5 distinct associated classes, which agrees with your formula.
$$\Bbb Z_4[i]=\{0,1,-1,i,-i,2,2i,1+i,1-i,i-1,-1-i,2i+1,2+i,2-i,2i-1\}$$
Notice first that the units in $\Bbb Z_4 [i]$ are $\{-1,1,-i,i,2i+1,2i-1,2+i,2-i\}$. Since $4=-(1-i)^4$ the ideals are $(1-i)^k$ for $k=0,1,2,3,4$, which gives:

*

*$(1)=(-1)=(i)=(-i)=(2i+1)=(2i-1)=(2+i)=(2-i)$

*$(1-i)=(1+i)=(-1-i)=(-1+i)$

*$(2)=(2i)$

*$(2+2i)$

*$(0)$
