Let $n$ be an integer, there is a well-known formula for $\varphi(n)$ where $\varphi$ is the Euler phi function. Essentially, $\varphi(n)$ gives the number of invertible elements in $\mathbb{Z}/n\mathbb{Z}$. My questions are:


1) Since Dedekind domains have the same factorization theorem for ideals analogous to that of the integers, can one define a generalized Euler phi function type for an ideal of a Dedekind domain, i.e, $\varphi(I)$ shall give the number of invertible elements in $R/I$, and is there a nice formula for it? It makes sense to me that perhaps the formula should resemble that of the integer, using the factorization of $I$ into prime ideals. But I do not have a concrete idea of what it should be.


2) What about domains that are not Dedekind, more specifically, what are the minimum hypotheses that one can impose on a domain so that one can have perhaps a formula for Euler phi function type on the ideals? I am not sure if this even makes sense at this point.



Generalized Euler phi function
Yes, there is a formula for $\varphi(I)$ in the case of number fields. Let $R$ be the ring of integers of a number field. As mentioned in Greg's comment, it suffices to consider the case $I=\mathfrak{p}^n$ where $\mathfrak{p}$ is a maximal ideal of $R$. Then we have a surjective ring morphism


\begin{equation}
\frac{R}{\mathfrak{p}^n} \to \frac{R}{\mathfrak{p}}
\end{equation}
such that the preimage of $(R/\mathfrak{p})^{\times}$ is exactly $(R/\mathfrak{p}^n)^{\times}$ (this is because $R/\mathfrak{p}^n$ is local). Thus $\varphi(\mathfrak{p}^n) = q^{n-1}(q-1)$ where $q=\operatorname{Card} (R/\mathfrak{p})$.


Note that there are Dedekind domains $R$ such that $R/I$ is never finite for $I \neq R$ : for example take $R=\mathbf{C}[T]$.


To define a function $\varphi$ for general rings, one would obviously need the hypothesis that $(R/I)^{\times}$ is finite, but then it is only clear that $\varphi$ is (weakly) multiplicative in the sense that $\varphi(I\cdot J) = \varphi(I) \varphi(J)$ if $I+J=R$.


