TITLE: Generalized Euler phi function
QUESTION [6 upvotes]: Let $n$ be an integer. There is a well-known formula for $\phi (n)$, where $\phi$ is the Euler phi function (totient). Essentially, $\phi(n)$ gives the number of invertible elements in $\mathbb{Z}/n\mathbb{Z}$.
Since Dedekind domains have the same factorization theorem for ideals analogous to that of the integers, one can define a generalized Euler phi function for an ideal $I$ of a Dedekind domain $R$, i.e. $\phi(I)$ gives the number of invertible elements of the factor ring $R/I$.
Moreover, $I$ factors uniquely into the product
$$I=P_1^{r_1}P_2^{r_2}\ldots P_k^{r_k}$$
with $P_i$ prime, distinct. By the Chinese remainder theorem, $R/I$ is isomorphic to the product of the $k$ rings $R/P_k^{r_k}$. Therefore $\phi$ is multiplicative. Hence it suffices to consider the case $I=P^n$, $P$ prime, non-zero. Here my first problem: what is the number of invertible elements in $R/P^n$? Imitating the case $R=\mathbb{Z}$, it should be $\phi(P^n)=q^{n-1}(q-1)$, where $q$ is the cardinality of $R/P$, but i've not a proof of this.
Consider this example. Let $K=\mathbb{Q}[i]$ be a quadratic number field and $R=\mathscr{O}_k$ its ring of algebraic integers. We know that $\mathscr{O}_K=\mathbb{Z}[i]$. For every ideal $I$ of $\mathscr{O}_K$, put $\phi_K(I)$ equal to the number of invertible elements of the factor ring $\mathscr{O}_K/I$. I want to compute
$$\phi(6630\mathscr{O}_K)$$
where $6630\mathscr{O}_K$ is the ideal generated by $6630$ in the extension ring $\mathscr{O}_K$ of $\mathbb{Z}$. This is what i did:

prime factorization: $6630=2\cdot3\cdot5\cdot13\cdot17$;
$2\mathscr{O}_K=(1+i)\mathscr{O}_K(1-i)\mathscr{O}_K$;
$3\mathscr{O}_K=3\mathscr{O}_K$;
$5\mathscr{O}_K=(1+2i)\mathscr{O}_K(1-2i)\mathscr{O}_K$;
$13\mathscr{O}_K=(3+2i)\mathscr{O}_K(3-2i)\mathscr{O}_K$;
$17\mathscr{O}_K=(1+4i)\mathscr{O}_K(1-4i)\mathscr{O}_K$

Hence 
$$\phi_K(6630\mathscr{O}_K)=\phi_K((1+i)\mathscr{O}_K)\phi_K((1-i)\mathscr{O}_K)\phi_K(3\mathscr{O}_K)\ldots\phi_K((1-4i)\mathscr{O}_K)$$
My problem is that i don't know how to compute cardinality of factor rings. For example, what is the cardinality of $\mathbb{Z}[i]/(1+i)\mathbb{Z}[i]$?..or the cardinality of $\mathbb{Z}[i]/(1+2i)\mathbb{Z}[i]$? The only fact i know is that all these factor rings are finite fields, hence of positive characteristic $p$, hence their cardinality is of the form $p^n$, but...what $p$, what $n$?
EDIT: ...the final result is $2^2\cdot 3\cdot 5^2\cdot 13^2\cdot 17^2=14652300$

REPLY [3 votes]: Your question is very similar to this question.
What I didnt see there in a quick look is how to compute the cardinality of $R/P^n$:
If $n=1$ this is a finite field as you remarked, and its characteristic is exactly the rational prime lying under $P$ (which is $P\cap\mathbb{Z}$). you can see this since there is a natural embedding of fields $\mathbb{Z}/P\cap\mathbb{Z}\to R/P$. The degree of this extension is called the "inertia degree" and is usually denoted by the letter $f$. Hence the cardinality of $R/P$ is $p^f$. (To actually compute the inertia degree, you can read this to get a formula using the discriminant).
In general, $n$ arbitrary, we can compute the order of $R/P^n$ most easily by localizing at $P$ ($R/P\equiv R_P/P_P$) and there $P$ is generated by a single element $\pi$. There is the short exact sequence of $R_P$ modules:
$$ 0\to (\pi^{n-1})/(\pi^n)\to R/P^n\to R/P^{n-1}\to 0$$
and since $(\pi^{n-1})/(\pi^n)$ is isomorphic to $R_P/(\pi)$ as an $R_P$ module, we get inductively the formula for the cardinality of $R/P^n$.