Question: Let $R, S$ be rings. If $f: R\rightarrow S$ is a mapping such that $f$ carries an idempotent to an idempotent. That is, If $a\in R$ is an idempotent element in $R$ then $f(a)$ is an idempotent element in $S$ then is $f$ is necessarily a ring homomorphism?
I know that, other direction holds! that is, a ring homomorphism carries an idempotent to an idempotent.
To solve a given question either I need to find a counter-example that is, the mapping between two rings that maps an idempotent to an idempotent but is not a ring homomorphism 'or' I need to prove this direction also holds... please help.
You could just take $f:\mathbb Z\to \mathbb Z$ and map every element to $1$.
Or if you want non-idempotents to map to non idempotents too, you could just use the map that interchanges $0$ with $1$ and leave everything else alone.
In some sense, the subset of functions from $\mathbb Z$ to $\mathbb Z$ that aren't ring homomorphisms is "huge" compared to the ones that are, and you shouldn't have a hard time finding an element that isn't a ring homomorphism (or even a group homomorphism.)