proving the characteristic of idempotent in ring Let $R$ be a ring, let $I$ be an ideal of $R$, and let $u\in R$ be idempotent modulo $I$ (that is, $u^{2}-u\in I$). Then $u$ can be lifted to an idempotent in $R$ in case there is an idempotent $e$ in $R$ with $e-u \in I$.  
I want to show that :  
Let $n > 1$ in $\mathbb{N}$. Prove that if $n$ is not a power of a prime, then there 
 exist idempotents modulo $n\mathbb{Z}$ in $\mathbb{Z}$ that cannot be lifted to idempotents in $\mathbb{Z}$
 A: If $n$ is not a prime power, then you can write $n=ab$ with $a,b\gt 1$, $\gcd(a,b)=1$. 
By the Chinese Remainder Theorem, there exists $x\in\mathbb{Z}$ such that $x\equiv 0\pmod{a}$ and $x\equiv 1\pmod{b}$. Since $x^2\equiv 0\equiv x\pmod{a}$ and $x^2\equiv 1\equiv x\pmod{b}$, it follows that $a|x^2-x$ and $b|x^2-x$, and since $\gcd(a,b)=1$, then $n|x^2-x$. Thus, $x$ is an idempotent modulo $n\mathbb{Z}$.
Now show that neither  $0-x$ nor $1-x$ are in $n\mathbb{Z}$. 
A: Suppose $n=p^rq$ with $p$ prime not dividing $q$ and $q\gt 1$ (i.e. $q$ divisible by some prime $l\neq p$).
Write a Bézout relation $1=ap^r+bq$ and define $e:=ap^r=1-bq \; $. Then:  
The element $\bar e\in \mathbb Z /n\mathbb Z$ is idempotent
Indeed in the isomorphism given by the Chinese remainder theorem $\mathbb Z /n\mathbb Z\simeq \mathbb Z /p^r\mathbb Z \times \mathbb Z /q \mathbb Z$ the element $\bar e =\overline {ap^r}= \overline {1-vq}$ is sent to $(0,1)$
The element $\bar e$ cannot be lifted to $1$ or $0$, the only idempotents in $\mathbb Z$
Indeed  it is clearly impossible to have $1= e+xn=ap^r+xp^rq$ .
And it is also impossible to have $0=e+xn = 1-bq+xp^rq $  (since $q$ does not divide $1$).
