Size of units of a finite ring Let $R$ be a finite commutative ring. I want to show that
$$
\#R^{\times}= \# R \cdot \prod_{\mathfrak p}\left(1-\frac{1}{\#(R/\mathfrak p)} \right),
$$
where the product runs over all maximal (equivalently prime,  since $R$ is finite) ideals of $R$.
My idea is to use the fact that $x \in R$ is a unit if and only if $x$ is not contained in any maximal ideal of $R$. The probability that a random $x \in R$ is not contained a maximal ideal $\mathfrak p$ is $\left(1-\frac{1}{\#(R/\mathfrak p)} \right)$ and hence the probability that $x$ is not contained in any maximal ideal is exactly $\prod_{\mathfrak p}\left(1-\frac{1}{\#(R/\mathfrak p)} \right)$.
However, I am not sure how to make this intuition precise to give me the desired result. Could anybody help me out with this approach or suggest an alternative one?
 A: An alternative approach.
Write $(0)=\mathfrak p_1^{k_1}\cap\dots\cap\mathfrak p_r^{k_r}$ with $\mathfrak p_i$ prime (maximal) ideals and $k_i\ge 1$. A first question occurs: are $\mathfrak p_1,\dots,\mathfrak p_r$ all prime (maximal) ideals of $R$? Yes, they are. If $\mathfrak p$ is another prime ideal, then, since $(0)\subseteq\mathfrak p$ there is $i$ such that $\mathfrak p_i\subseteq\mathfrak p$, and since both are maximal we have $\mathfrak p_i=\mathfrak p$.
Then by using CRT we get $R\simeq R/\mathfrak p_1^{k_1}\times\dots\times R/\mathfrak p_r^{k_r}$ and therefore $$R^\times\simeq(R/\mathfrak p_1^{k_1})^\times\times\dots\times(R/\mathfrak p_r^{k_r})^\times.$$ Now let us count: $|R^\times|=\prod_{i=1}^r|(R/\mathfrak p_i^{k_i})^\times|$ and $|R|=\prod_{i=1}^r|R/\mathfrak p_i^{k_i}|$. It follows that $$|R^\times|/|R|=\prod_{i=1}^r|(R/\mathfrak p_i^{k_i})^\times|/\prod_{i=1}^r|R/\mathfrak p_i^{k_i}|=\prod_{i=1}^r|(R/\mathfrak p_i^{k_i})^\times|/|(R/\mathfrak p_i^{k_i})|.$$
Since $R/\mathfrak p_i^{k_i}$ is a local ring with maximal ideal $\mathfrak p_i/\mathfrak p_i^{k_i}$ we have $(R/\mathfrak p_i^{k_i})^\times=(R/\mathfrak p_i^{k_i})\setminus(\mathfrak p_i/\mathfrak p_i^{k_i})$. Thus $|(R/\mathfrak p_i^{k_i})^\times|=|R/\mathfrak p_i^{k_i}|-|\mathfrak p_i/\mathfrak p_i^{k_i}|$, and then $|(R/\mathfrak p_i^{k_i})^\times|/|(R/\mathfrak p_i^{k_i})|=1-\dfrac{|\mathfrak p_i/\mathfrak p_i^{k_i}|}{|R/\mathfrak p_i^{k_i}|}$. Now recall that $\dfrac{R/\mathfrak p_i^{k_i}}{\mathfrak p_i/\mathfrak p_i^{k_i}}\simeq R/\mathfrak p_i$ and conclude that $\dfrac{|\mathfrak p_i/\mathfrak p_i^{k_i}|}{|R/\mathfrak p_i^{k_i}|}=\dfrac{1}{|R/\mathfrak p_i|}$.
