I've spent a lot of time looking for examples, and I can't find any commutative rings which have a finite number of idempotents other than a power of $2$. Intuitively, adjoining an extra idempotent $a$ always seems to double the number, as for every other idempotent $b$, $ab$ is a new idempotent. But there doesn't seem to be any way to turn this into a proof. I'm not sure whether it's even true.
I have managed to prove the characteristic $2$ case, as there the idempotents form a subring, and hence $\mathbb{Z}_2$-Algebra. But this doesn't seem to be any help for the other cases. I'm sorry I can't show more of an attempt, but this really has me stumped.
So are there commutative rings with a finite number of idempotents which don't have $2^n$ idempotents for some $n$?
I also don't know of any rings that have $k \ne 2^n$ idempotents in the noncommutative case, but I haven't investigated that much.
Best Answer
Let $(A,+,\cdot)$ be a commutative ring and let $E$ be its set of idempotents. Define a binary operation $\&$ on $E$ by
$$e_1 \& e_2 = e_1 + e_2 - 2e_1e_2.$$
Then (exercise!) $(E,\&,\cdot)$ is a well-defined commutative ring of characteristic $2$. If $E$ is finite, it follows that $\lvert E \rvert$ is a power of $2$.