[Math] Function that is discontinuous only for integer fractions

analysiscontinuityfunctions

I have this question:

Find a function $f :\mathbb R \to\mathbb R$ which is discontinuous at the points of the
set $\{\frac1n : n \text{ a positive integer}\} \cup \{0\}$ but is continuous everywhere
else.

I really don't know what to do. I was thinking maybe:
$$
f(x) =
\begin{cases}
1 \quad&\text{if }x=0 \\
0 &\text{if } x \text{ is in } \{\tfrac1n : n \text{ a positive integer}\}\\
x &\text{otherwise}
\end{cases}
$$
But that kind of seems like 'cheating'. Is there a better example?

EDIT: Would it be better to have:

$$
f(x) =
\begin{cases}
1 &\text{if } x \text{ is in } \{\tfrac1n : n \text{ a positive integer}\}\cup \{0\}\\
0 &\text{otherwise}
\end{cases}
$$

Best Answer

You can modify the fractional part function: $ \{x\} = \lceil x \rceil - x $, which is discontinuous at integers; to

$$ f(x) = \begin{cases} 0 & ; x = 0 \\ \left\{\dfrac{1}{x}\right\} & ; otherwise \end{cases} $$