Let $D = { x_1, x_2, X_3, …}$ be an arbitrary countably infinite set of reals. Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be goven by
\[f(x) = \sum_{n \in \mathbb{N}; x_n < x} \frac{1}{2^n}\]For any real number $x$, the set
\[n \in \mathbb{N} : x_n < x\]is finite. Indeed, since $D$ is a countable infinite set, we can list its elements in increasing order as
\[x_1 < x_2 < x_3 < \cdots.\]For any fixed $x$, there can be only finitely many indices $n$ for which $x_n < x$. Therefore, the defining sum for $f(x)$ includes only finitely many terms, and hence $f(x)$ is well-defined.
Let $x < y$. We compute
\[f(y) - f(x)b = \sum_{\substack{n \in \mathbb{N} \ x \le x_n < y}} \frac{1}{2^n}.\]The set $n: x \le x_n < y$ may be empty or may contain some indices, but every summand is nonnegative. Thus,
\[f(y) - f(x) \ge 0,\]so
\[f(x) \le f(y).\]Hence, $f$ is non-decreasing.
Let $x_k \in D$. We show that $f$ is discontinuous at $x_k$.
Consider $f(x_k)$ and $f(x_k - \varepsilon)$ for small $\varepsilon > 0$. We have
\[f(x_k) - f(x_k - \varepsilon) = \sum_{\substack{n \in \mathbb{N} \ x_k - \varepsilon \le x_n < x_k}} \frac{1}{2^n}.\]As $\varepsilon \to 0^+$, the only index for which
$x_k - \varepsilon \le x_n < x_k$ holds is $n = k$, so
\[f(x_k) - f(x_k - \varepsilon) \to \frac{1}{2^k}.\]Thus, $f$ has a jump discontinuity of size $\frac{1}{2^k}$ at $x_k$.
Hence $f$ is discontinuous at every point of $D$.
Now let $x \notin D$. We show that $f$ is continuous at $x$.
Given $\varepsilon > 0$, choose $N$ such that
\[\sum_{n = N+1}^\infty \frac{1}{2^n} < \varepsilon.\]Since $D$ is a discrete set, there exists $\delta > 0$ such that the interval
$x - \delta, x + \delta$ contains at most some of the finitely many points
| $x_1, x_2, \ldots, x_N$, and no others. Therefore, when $ | h | < \delta$, |
Thus, $f$ is continuous at every point outside $D$.
$\square$
(I’m not sure whether the explanation above is entirely correct. If you happen to notice any mistakes, I would really appreciate it if you could leave your suggestions in the comments when you have a moment. Thank you very much for your help and corrections.)