# How many idempotent elements does the ring ${\bf Z}_n$ contain?

Let $R$ be a ring. An element $x$ in $R$ is said to be idempotent if $x^2=x$. For a specific $n\in{\bf Z}_+$ which is not very large, say, $n=20$, one can calculate one by one to find that there are four idempotent elements: $x=0,1,5,16$. So here is my question:

Is there a general result which tells the number of the idempotent elements of ${\bf Z}_n$?

If $n=p_1^{m_1}\cdots p_k^{m_k}$ is the factorization of $n$ as a product of powers of distinct primes, then the ring $\mathbb Z/n\mathbb Z$ is isomorphic to the product $\mathbb Z/p_1^{m_1}\mathbb Z\times\cdots\times \mathbb Z/p_k^{m_k}\mathbb Z$. It is easy to reduce the problem of counting idempotent elements in this direct product to counting them in each factor.

Can you do that?

• I don't know much about abstract algebra but some basic definitions. I guess the idea is similar/related to the Fundamental Theorem of Finite Abelian Groups, isn't it? – Jack Jun 16 '11 at 16:43
• (I guess you mean the idea of the isomorphism I mentioned?) It is related to that. It is, in fact, a form of the Chinese Remainder Theorem (see Wikipedia, for example) – Mariano Suárez-Álvarez Jun 16 '11 at 16:45
• What do you mean by "counting them in each factor"? Do you mean counting the idempotent elements in each ${\bf Z}_{p_i^{m_i}}$ and then add them up? – Jack Jun 16 '11 at 16:59
• @Jack: I mean that if you know how many idempotents there are in each factor it is not hard to know how many idempotents there are in the product. This follows from the following simple observation: an element $(a,b)$ in a direct product of two rings $A\times B$ is idempotent if and only if $a$ is idempotent in $A$ and $b$ is idempotent in $B$. – Mariano Suárez-Álvarez Jun 16 '11 at 17:02
• Fair enough. Now I see. Thanks! – Jack Jun 16 '11 at 17:06

In $\Bbb{Z}_n$ the relation $x^2=x$ is equivalent to $(x-1)x\equiv 0 ( mod \ n)$, that is $n | x(x-1)$. This is an easy way to calculate all idempotent elements for small $n$. In general, you need to consider the factorization of $n$ in prime factors and note that $x,x-1$ are coprime, and if one prime number divides one of them, it can't divide the other.

HINT $\$ Idempotents in $\rm\:\mathbb Z/n\:$ are closely related to factorizations of $\rm\:n\:$ into coprime factors, i.e. $\rm\: n = a\:b\:,\:$ where $\rm\:gcd(a,b) = 1\:.\$ Indeed, notice that $\rm\:p^k\ |\ e\:(e-1)\ \Rightarrow\ p^k\ |\ e\:$ or $\rm\:p^k\ |\ e-1\:.$

• So are you saying the number of idempotent elements in Z_n is 2^(omega(n)) where omega(n) is the number of distinct prime factors of n.? Is there a way to determine which elements of Z_n are idempotent. For example, (by a brute force Mathematica code I see that ) for n=200 the idempotents are {0,1,25,176}. Is there any "formula" for finding the idempotents in Z_n? – Geoffrey Critzer Jul 6 '15 at 22:33

$n\geq 1$ be an integer and consider the ring $R=\mathbb{Z}/\mathbb{Z}_{n}$. First of all, we can see that the number of all the idempotents elements of $R$ is $2^m$, where $m$ is the number of distinct prime divisor of $n$.

$\textbf{Proof:}$Let $n=\prod\limits_{i=1}^{n} p_{i}n^{i}$ be the prime factorization of $n$ and $R_{i}=\mathbb{Z}/p_{i}^{n_{i}}$. By the Chinese Remainder theorem we have $R\cong R_{1}$ x $\cdots$ x $R_{m}$, say $(1)$.

$\textbf{Claim:}$ If $p$ is a prime and $l>0$ is an integer, then the only idempotent element of $\mathbb{Z}/p^{l}\mathbb{Z}$ are $0$ and $1$.

$\textbf{Proof:}$So we wnat to show that modulo $p^{l}$, the equation $x^{2}\equiv x$ (mod $p^{l})$ has only two trivial solutions $x=0,1$. Suppose that $x\neq 0$ is a solution of $x^{2}\equiv x$ (mod $p^{l})$. We will show that $x\equiv 1$ (mod $p^{l})$.

Let $x=p^{r}s$, where $0\leq r<1$, and gcd($s, p)=1$. Then $s(p^{r}s-1)\equiv 0$ (mod $p^{l-r})$ which give us $p^{r}s\equiv 1$ (mod $p^{l-r})$. Thus $r=0$ and hence $x\equiv s\equiv 1$ (mod $p^{l})$. It is clear now from (1) and claim that the number of idempotents of ring $R=\mathbb{Z}/\mathbb{Z}_{n}$ is $2^{m}$.

Now we can solve any question for $\mathbb{Z}/\mathbb{Z}_{n}$.

By the above $R=\mathbb{Z}/\mathbb{Z}_{20}$, we know that $R$ has $4$ idempotents, it is clear two of them being $0, 1$ (mod $20$). Let $R_{1}=\mathbb{Z}/\mathbb{Z}_{4}$, $R_{2}=\mathbb{Z}/\mathbb{Z}_{5}$. Then $R\cong R_{1}$ x $R_{2}$. All idempotents of $R_{1}$ x $R_{2}$ are $(0, 0)$, $(1, 0)$, $(0, 1)$, $(1, 1)$.

So we just need to find preimage of each idempotent in $R$. Obviously, the preimages of $(0, 0)$ and $(1, 1)$ are $0$ and $1$ (mod $20$) respectively. Now let let's find the preimage of, say $b=(0, 1)$. Let $a=m+20\mathbb{Z}$ be the preimage of $b$. Then the image of $a$ is $(m+4\mathbb{Z}, m+5\mathbb{Z})=b=(4\mathbb{Z}, 1+5\mathbb{Z})$. So $m$ divisible by $4$ and it is equiavlent to $1$ (mod $5$). It follows that $a=16+20\mathbb{Z}$. Similarly, we can find another idempotent 5 which is preimage of $(1,0)$.