$\displaystyle f(x)=\begin{cases} \frac{q}{q+1}\mbox{ if }x=\frac{p}{q}\mbox{ is a rational number}\\ 0\mbox{ if }x\mbox{ is irrational or }0 \end{cases}$
It is assumed here that $\displaystyle \gcd(p,q) = 1$ and $\displaystyle q > 0$ so that the function is well-defined and nonnegative.
I have to show that there is no such closed interval on which $\displaystyle f(x)$ has maximum although it is bounded.