I asked [this question at MSE](https://math.stackexchange.com/questions/1772552/some-examples-of-clean-topological-spaces) but I did not received any answer, so I repeat it here at MO:


What is an example of a Hausdorff topological space $X$, not a singleton, such that the ring $C(X)$ of all real (or complex) valued continuous functions on $X$ is a **clean ring**?


A clean ring is a ring in which every element is a sum of a unit and an idempotent.



Some examples of clean topological spaces
Well, the two point set will do. Also an infinite discrete set will do.
To give a less obvious example, let me argue that every compact space with a basis of clopen sets will do too.


Let $X$ be such and consider a real valued function $f$ on $X$.
Consider the compact subset $\{f \leq 1/3\}$ and cover it with clopen sets that are contained in $\{f<2/3\}$. Choose a finite subcover and let $p$ be the characteristic function of its union. This is a continuous idempotent. $u=f-p$ is a continuous function that is bounded away from 0, hence a unit. $f=p+u$.


