Let $(a_n)$ be a sequence of positive numbers and define $$f(x) = \begin{cases}a_n, \text{ if } x = 1/n, \ \ n \geq 1\\ 0, \text{otherwise}\end{cases}.$$Show that $f$ is of bounded variation on $[0,1]$ iff $\sum_na_n < \infty$.
One of the directions is easy to see: For if $\sum_n a_n < \infty$ then $$\sum_{k=0}^{n-1}|f(x_{k+1})-f(x_k)| \leq \sum_{k=0}^{n-1}|a_{k+1}-a_k| \leq 2\sum_{k=0}^\infty a_{k+1} - a_0 < \infty,$$for each partition $(x_n)$ of $[0,1]$.
However, the reverse direction I am having some trouble. I tried the following \begin{align} |a_{k+1}| & = |f(x_{k+1})|,\\ & \leq |f(x_{k+1}) - f(x_k)| + |f(x_k)|,\\ & \leq |f(x_{k+1})-f(x_k)| + \lvert f \rvert_\infty. \end{align} Adding up to $n-1$ we see that $$\sum_{k=0}^{n-1}|a_{k+1}| \leq C + n\lvert f\rvert_\infty.$$But clearly I can't let $n \rightarrow \infty$ because we don't have convergence.
Ok I think I found out a way to work around this. We just take a point that can't be written as $1/n$, say $x_0$. Then $$|a_{k+1}| = |f(x_{k+1})-f(x_0)|.$$Adding from $0$ to $n-1$ we have $$\sum_{k=0}^{n-1}|a_{k+1}| = \sum_{k=0}^{n-1}|f(x_{k+1})-f(x_0)| \leq C.$$Now we can take the limit and we obtain the convergence of $\sum_na_n$! I would like to ask if anyone can confirm this reasoning.