Take the interval $I=[0,1]$ and the sequence $\{x_n\}_{n\in\Bbb{N}}$ defined as follows:
$$x_n=\sum_{k=1}^n \frac{1}{2^k}, \forall n \in \Bbb{N}$$ and $x_0=0$. Now, that sequence defines a partition for the interval $I$. Let's define the function $f$ such that $f(0)=0, f(1)=1$ and for all other $x\in I$, if $x_{i-1}<x\leq x_i$ then $f(x)=x_i$, where $i \in \Bbb{N}$. This funcion should look like this:
Did I define it correctly? Is there another way to define this function in a more elegant/short way? Bonus points if someone could post a plot of this function where the area "under the curve" is shown!
Edit: Is the area under the function equal to $\frac{1}{2}$?
Thanks in advance!

$$x_n=\sum_{k=1}^n \frac{1}{2^k}=1-\frac{1}{2^n} \tag 1$$ $$2^n=\frac{1}{1-x_n}$$ $$n=\frac{-\ln(1-x_n)}{\ln(2)} \tag 2$$ Eq.$(2)$ is only valid for the discret values of $x$ defined by Eq.$(1)$.
If we want to extend to continuous $x$ we have to use the celling or the floor functions, respectively noted $\lceil\:\rceil$ and $\lfloor\:\rfloor$ :
http://mathworld.wolfram.com/CeilingFunction.html
http://mathworld.wolfram.com/FloorFunction.html
$$n=\left\lceil{\frac{-\ln(1-x)}{\ln(2)}}\right\rceil=1+\left\lfloor{\frac{-\ln(1-x)}{\ln(2)}}\right\rfloor$$ Thus, the equation represented on your graph is : $$f(x)=1-\frac{1}{2^{1+\left\lfloor{\frac{-\ln(1-x)}{\ln(2)}}\right\rfloor}}$$
$$A=\int_0^1 f(x)dx=\sum_{n=1}^\infty f(x_n)(x_n-x_{n-1})$$ $$A = \sum_{k=1}^n \left(1-\frac{1}{2^n}\right)\left((1-\frac{1}{2^n})-(1-\frac{1}{2^{n-1}}) \right) =\sum_{k=1}^n \left(1-\frac{1}{2^n}\right)\frac{1}{2^{n}}$$ $$A = \sum_{k=1}^n\frac{1}{2^n}-\sum_{k=1}^n\frac{1}{2^{2n}}=1-\frac13$$ $$\int_0^1 f(x)dx=\frac23$$