How can I show that this strange function is continuous at irrational points?

Since $\mathbb{Q}$ is countable, there exists a bijection $q: \mathbb{Z}^+ \longrightarrow \mathbb{Q}$, so we can write any rational as $q(n)$ for some $n \in \mathbb{Z}^+$.

Define function $g: \mathbb{Q} \longrightarrow \mathbb{R} \,$ as $\, g(q(n)) := 2^{-n}$, and function $f: \mathbb{R} \longrightarrow \mathbb{R}$ as $$ f(x) := \sum_{r \in \mathbb{Q}, \, r<x} g(r) $$ Then I want to show that $f$ is continuous at a irrational point $c$, so I need to find a $\delta(\varepsilon) > 0$ such that when $c,x$ are within $\delta$ from each other, $f(c),f(x)$ are within $\varepsilon > 0$ from each other.

My attempt was to first look at $x>c$ and try to show that there is a $\delta$ such that $$ \sum_{r \in \mathbb{Q}, \, c<r<c+\delta} g(r) $$ gets arbitrarily small, but I just have no clue how. It doesn't seem like I have much control over this function.

A hint was that I should first show that $f_n: \mathbb{R} \longrightarrow \mathbb{R}$ $$ f_n(x) := \sum_{r \in \mathbb{Q}, \, r<c, \, g(r) \geq 2^{-n}} g(r) $$ is continuous at $c$ for any $n \in \mathbb{Z}^+$, but again, I have no idea how.

Hints are much welcomed.


Let $c$ be irrational and $\epsilon>0$. Pick $N$ with $2^{-N}<\epsilon$. Pick $\delta>0$ such that $(c-\delta,c+\delta)$ avoids $q(1),q(2), \ldots, q(N)$, e.g., let $\delta=\min\{|q(1)-c|,\ldots,|q(N)-c|\}$. Then for $x\in(c-\delta,c+\delta)$, $$|f(x)-f(c)|\le\sum_{n>N}g(q(n))=2^{-N}<\epsilon.$$


Just for reference, here is another approach assuming familiarity with uniform convergence.

For each $A\subseteq\mathbb{R}$, define the indicator function $\mathbf{1}_A : \mathbb{R} \to \mathbb{R}$ by

$$ \mathbf{1}_A (x) = \begin{cases} 1, & x \in A \\ 0, & x \notin A \end{cases} $$

Then we find that

$$ f(x) = \sum_{r\in\mathbb{Q}} g(r)\mathbf{1}_{(r,\infty)}(x) = \sum_{n=1}^{\infty} \frac{1}{2^n} \mathbf{1}_{(q(n), \infty)}(x). $$

Moreover, each summand is continuous at each point of $\mathbb{R}\setminus\mathbb{Q}$, and this series converges uniformly on $\mathbb{R}$ by the Weierstrass $M$-test. Therefore $f$ is also continuous at each point of $\mathbb{R}\setminus\mathbb{Q}$.