Proving idempotent elements in $\mathbb{Z}_n$ I'm working in $\mathbb{Z}_n$ under multiplication  (not addition) for some time now and I'm beginning to notice something:
For $n \in \mathbb{N}$ where $n$ is even and $\frac{n}{2}$ is odd, it seems to be always true that $\frac{n}{2}$ is idempotent, i.e. $(\frac{n}{2})^2 \equiv \frac{n}{2}$ mod $n$ when $n$ satisfies the aforementioned definition.
So I wanna try to prove this but I don't know how to approach it. My first thought was induction since this iterates across $n \in \mathbb{N}$ satisfying my definition of $n$.

Proof
Let $n \in \mathbb{N}$ such that $n$ is even and $\frac{n}{2} = 2k+1$ for some other $k \in \mathbb{N} \cup \{0\}$ (Note that $k$ could equal $0)$
Define $P(n)$ as the statement:$(\frac{n}{2})^2 \equiv \frac{n}{2}$ mod $n$
Our basis case would be $P(2): (\frac{2}{2})^2=(1)^2 \equiv 1$ mod $2 \equiv \frac{2}{2}$ mod $2$ So $P(2)$ holds as true.
Assume $P(i)$ is true for some $i \in \mathbb{N}$ where $i = 2(2k+1)$.
Inductively, then we have:
$$P(i+1): (\frac{i+1}{2})^2 =  ?? $$

Then I get stuck here and don't know how to proceed. Obviously, I can't do much once I put $k$'s into the equation because $k$ can be any number. All we know about $k$ is that $k \leq n$ by how we defined $n$.
 A: You want to prove $k^2\equiv k \bmod 2k$ when $k$ is odd, this is equivalent to proving $k^2-k = k(k-1)$ is a multiple of $2k$. Since $k$ divides $k$ and $2$ divides $k-1$ we have $2k$ divides $k(k-1)$.
What we used here is that if $d$ divides $a$ and $e$ divides $b$ then $de$ divides $ab$. This can be proved by writing $a$ as $dk$ and $b$ as $el$ and then writing $ab$ as $(ed)(kl)$.
A: In any $\mathbb{Z}_n,$ computing idempotents is equivalent to solving the congruence $$x^2 \equiv x \pmod{n}$$ or $x(x-1)=ny$ for some $y\in\mathbb{Z}$.
In your case, $n=2(2m+1),$ so, choose $x=2m+1$ and $y=m.$
A: A factor $\,k\,$ of modulus $\,n=jk\,$ is idempotent $\!\bmod n\!\iff\! \color{#c00}{k\equiv 1}\,$ mod its cofactor $\,j,\,$ by
$$\ jk\mid (k\!-\!1)k\iff j\mid \color{#c00}{k\!-\!1}.\ \text{ OP is case } \,j=2,\ k = n/2\qquad$$
Notice  that here $\,k\,$ is coprime to $\,j.\,$ This is a characteristic property of idempotents, namely generally idempotents in $\:\Bbb Z_{ n}\:$ correspond to factorizations of $\:n\:$ into two coprime factors. For if $\:e^2 = e\in\Bbb Z_n\:$ then $\:n\mid (e\!-\!1)e\:$ thus $\:n = jk,\ j\:|\:e\!-\!1,\ k\mid e,\:$ so $\:(j,k)= 1\:$ by $\:(e\!-\!1,e) = 1.\:$ Conversely if $\:n = jk\:$ for $\:(j,k)= 1,\:$ then by CRT, $\:\Bbb Z_n\cong \Bbb Z_j\times \Bbb Z_k\:$ which has nontrivial idempotents $\:(0,1),\,(1,0).\:$
