André Henriques answer for a closed set $C$ can easily be improved to $C^\infty$ by considering $e^{1/(\alpha-x)+1/(x-\beta)}$ if $x\not\in C$ where $\alpha$ is the supremum of all elements $<x$ in $C$ and where similarly $\beta$ is the infimum of all elements $>x$ in $C$.
Roland Bacher
- 17.9k
- 3
- 45
- 113