Question: If both $k$, $k+1$ are idempotents in $\mathbb{Z}_n$ and $k≠0$ then $n=2k$
My attempt: since $k$, $k+1$ are idempotents in $\mathbb{Z}_n$ Hence we have,
$k^2\equiv k\mod n$
and $(k+1)^2\equiv k+1\mod n$
$\implies k^2+2k+1\equiv k+1\mod n$
$\implies k+2k+1\equiv k+1\mod n$
$\implies 2k\equiv 0\mod n$
So that $n\vert\text{ } 2k$.
How to conclude that $n=2k$ ?
(Above is an excercise from book 'Contemporary abstract algebra' by Gallian)
$k\in\{0,1,\dots,n-1\}$, so $2k\in\{0,1,\dots,2n-2\}$. (In fact, we have to assume $k+1<n$, too.) Since $n\mid 2k$ it follows that $2k=n$.