# Function that is discontinuous only for integer fractions

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}$$

-
Looks like Thomae's function: en.wikipedia.org/wiki/Thomae's_function –  Austin Mohr Jan 25 '13 at 13:35
Actually a later part of this question seems to involve that function. –  Joe Jan 25 '13 at 13:38
That's not cheating at all, as long as the function is well defined (it certainly is) and it verifies the requisites (does it?) –  leonbloy Jan 25 '13 at 14:11
It does verify the requisites right? f(x) = 0 as x tends to 0 but f(0)=1 which is not the same, so it's discontinuous at 0, Same for all the 1/n as well, unless I've got this very wrong. –  Joe Jan 25 '13 at 16:38
I fully agree with @leonbloy. Since the function satisfies the assumptions, it is a correct answer. It is good in that it is simple, so you immediately see what happens. That possibly makes it better than any "natural" example. –  Feanor Apr 8 '13 at 8:11