# Petr function

Let $x \in [0,1]$ have decimal representation $x=\displaystyle\sum_{k=1}^{\infty} \dfrac{a_k}{10^k}$, where $a_k \in \{0,1,\ldots,9\}$. The Petr function $P_K \colon [0,1] \rightarrow \mathbb{R}$ is defined by $$P_K(x)=\displaystyle\sum_{k=1}^{\infty} \dfrac{c_k b_k}{2^k},$$ where $b_k = a_k \mod 2, c_1=1$, and for $k \geq 2$, $$c_k = \left\{ \begin{array}{ll} -c_{k-1} &; a_{k-1} \in \{1,3,5,7\}, \\ c_{k-1} &; \mathrm{otherwise}. \end{array} \right.$$