# McCarthy function

The McCarthy function $M$ is defined by $$M(x) = \displaystyle\sum_{k=1}^{\infty} \dfrac{1}{2^k} g \left( 2^{2^k} x \right),$$ where $$g(x) = \left\{ \begin{array}{ll} 1+x &; x \in [-2,0] \\ 1-x &; x \in [0,2], \end{array} \right.$$ and $g(x+4)=g(x)$ for any $x \in \mathbb{R}$.