Let $f_{0}(x):[0,1]\to[0,1]$ be defined by
$$f_{0}(x):=\begin{cases} 3x, & \text{if } x\in [0,\frac{1}{3}] \\ \\ -3x+2, & \text{if } x\in (\frac{1}{3}, \frac{2}{3}] \\ \\ 3x+2, & \text{if } x\in (\frac{2}{3},1] \end{cases} $$
Construct a sequence of function such that
$$f_{n+1}(x):=\begin{cases} \frac{1}{3}f_n(3x), & \text{if } x\in [0,\frac{1}{3}] \\ \\ \frac{1}{3}+\frac{1}{3}f_n(3x-1), & \text{if } x\in (\frac{1}{3}, \frac{2}{3}] \\ \\ \frac{2}{3}+\frac{1}{3}f_n(3x-2), & \text{if } x\in (\frac{2}{3},1] \end{cases},\;\; \forall n\in\mathbb{N}. $$
And then, take the series associated with this sequence.
$$f(x):=\sum_{i=0}^{\infty}(-1)^{i}f_i(x).$$
How do I plot some $f_n(x)$ (in function of n) and a good approximation for $f$? I want a plot of then separately and one in the same picture (with more than one $f_n$). Is it possible to make a "zoom" on the picture?
Furthermore, is it possible to create a simulation in which one gives a natural number $p$ as an input, and receives as output the graph of some $f_n$ (in function of n) and a good approximation for $f$?
$$f_{n}(x):=\begin{cases} \frac{1}{p}f_{n-1}(px), & \text{if } x\in [0,\frac{1}{p}] \\ \\ \frac{1}{p}+\frac{1}{p}f_{n-1}(px-1), & \text{if } x\in (\frac{1}{p}, \frac{2}{p}] \\ \\ .\\ .\\ .\\ \\ \frac{p-1}{p}+\frac{1}{p}f_{n-1}(px-p-1), & \text{if } x\in (\frac{p-1}{p},1] \end{cases} $$


