## The dynamics of a trick

### Proof

When $$D \geq 3$$ is odd, the cycles are obtained from the cycles of $$D-1$$ by putting a $$0$$ or a $$9$$ in the middle of each element of the cycle. And the number of cycles of $$N_{D}$$ is equal to the number of cycles of $$N_{D-1}$$.

Let us begin with an example. Consider $$D=5$$ and $$n=21978$$. Subtracting $$n$$ to $$i_{5}(n)$$ we get $$65\mathbf{9}34$$. The natural number $$n$$ belongs to a cycle of period $$2$$, namely $$\{21\mathbf{9}78, 65\mathbf{9}34\}$$. Notice that, if $$n'=2178$$, then subtracting $$n'$$ to $$i_{4}(n')$$ we get $$6534$$, with $$\{2178, 6534\}$$ being a cycle of period $$2$$ of $$N_{4}$$. Similarly, if $$n=089108910$$, then subtracting $$n$$ to $$i_{9}(n)$$ we obtain $$069306930$$, and the difference from $$i_{8}(n')$$ to $$n'=08918910$$ is $$06936930$$. The natural $$n$$ belongs to a cycle of period $$5$$, namely $\{009900990, 089108910, 069306930, 029702970, 049504950\},$ and $\{00990990, 08918910, 06936930, 02972970, 04954950\}$ is a cycle of $$N_{8}$$ with the same period.

In general, if $$D>1$$ is odd and $n = a_{D-1} a_{D-2} ... a_{\frac{D+1}{2}} a_{\frac{D-1}{2}} a_{\frac{D-3}{2}}... a_{0}$ belongs to $$N_{D}$$, we have $f_{D}(n) = \left|\left[10^{D-1}-1\right]\left[a_{D-1}-a_{0}\right]+\left[10^{D-2}-10\right]\left[a_{D-2}-a_{1}\right]+...+ \\ \;\;\;\;+\left[10^{\frac{D+1}{2}}-10^{\frac{D-3}{2}}\right]\left[a_{\frac{D+1}{2}}-a_{\frac{D-3}{2}}\right]+\left[10^{\frac{D-1}{2}}-10^{\frac{D-1}{2}}\right]\left[a_{\frac{D-1}{2}} - a_{\frac{D+1}{2}}\right]\right|=\\ =\left|\left[10^{D-1}-1\right]\left[a_{D-1}-a_{0}\right]+\left[10^{D-2}-10\right]\left[a_{D-2}-a_{1}\right]+...+ \\ \;\;\;\;+ \left[10^{\frac{D+1}{2}}-10^{\frac{D-3}{2}}\right]\left[a_{\frac{D+1}{2}}-a_{\frac{D-3}{2}}\right]\right|=\\= f_{D-1}(n'), \mbox{ modulo a 9 or a 0 at the central position,}$ where $$n'$$ is the natural number which is obtained from $$n$$ by pulling out the central digit. Notice that the central digit of $$f_{D}(n)$$ is $$9$$ if the subtraction $$|a_{\frac{D+1}{2}} - a_{\frac{D-3}{2}}$$| leaves a reminder, and in that case such a reminder also exists in the computation of the value of $$f_{D-1}(n')$$; and it is $$0$$ in both computations otherwise. That is, the orbit of $$n$$ by $$f_{D}(n)$$ must end in a cycle $$\gamma$$ which comes from the cycle $$\alpha$$ of $$N_{D-1}$$ where the orbit of $$f_{D-1}(n')$$ ends, putting a $$0$$ or a $$9$$ in the middle of each element of $$\alpha$$.

Since the orbit of each element of $$N_{D}$$ ends in a cycle, it follows that each cycle $$\alpha$$ of $$N_{D-1}$$ must produce some cycle $$\gamma$$ of $$N_{D}$$ when putting a $$0$$ or a $$9$$ at the cental position of some of the elements of $$\alpha$$. And which digit should one place there? Notice that, in the tables for $$D$$ odd between $$3$$ and $$9$$, all elements of such a cycle $$\gamma$$ have digit $$0$$ at the central position, or all have digit $$9$$ in that position; for $$D=11$$, however, in the cycle $\{01143966780, 07622967330, 04246044660, 02398019580, 06193069740,\\ 01397030580, 07106048730, 03321988560, 03266923770, 04466042460,\\ 01958023980, 06974061930, 03058013970, 04873071060\}$ some elements of the cycle have a central $$0$$ and others a $$9$$. In general, if we fix an element $$n'$$ of the cycle $$\alpha$$ of $$N_{D-1}$$, with period $$p$$, the digit that is added to the central position of $$\alpha$$ in order to obtain $$n$$ from a cycle of $$N_{D}$$ is that one which is consistent with the equality $$(f_{D})^{p}(n)=n$$. These remarks guarantee that the number of cycles of $$N_{D}$$ is greater or equal than the number of cycles of $$N_{D-1}$$.

But, in fact, the number of cycles in $$N_{D}$$ is equal to the number of cycles in $$N_{D-1}$$. This is a consequence of the following property: if we obtain a cycle of $$N_{D}$$ by adding a $$9$$ in the central position of a cycle of $$N_{D-1}$$, then if, instead of $$9$$, we add a $$0$$ in that position, we do not obtain a cycle; and conversely. Let us see why.

Given $$D$$ odd, suppose we obtain a cycle $$\gamma$$ of $$N_{D}$$ $\gamma = a_{D-2} a_{D-3} ... a_{\frac{D-1}{2}} \,c\, a_{\frac{D-3}{2}}...a_{1} a_{0}$ by adding a digit $$c$$, which we already know to be either $$0$$ or $$9$$, in the central position of a cycle $$\alpha$$ of $$N_{D-1}$$, $\alpha = a_{D-2} a_{D-3} ... a_{\frac{D-1}{2}} a_{\frac{D-3}{2}}... a_{1} a_{0}.$

Then the central digit of $$f_{D}(\gamma)$$ depends on the existence of a reminder $$1$$ coming from the difference $$\left|a_{\frac{D-1}{2}} - a_{\frac{D-3}{2}}\right|$$, naturally influenced by subtractions on digits placed at the right side of these ones: if the difference has a reminder, then the central digit of $$f_{D}(\gamma)$$ is $$9$$ independently of the value of $$c$$; if there is no reminder, then it is $$0$$, whatever the value of $$c$$. This indicates that, if $$c=9$$ and, instead of $$9$$, we had placed a $$0$$ at the central position of $$\alpha$$, we would obtain, applying $$f_{D}$$, the same value $$f_{D}(\gamma)$$. That is, that other element of $$N_{D}$$ is in the preimage of $$\gamma$$, it does not give a new cycle. A similar argument is used if $$c=0$$, thus showing that each cycle of $$N_{D-1}$$ generates one and only one cycle of $$N_{D}$$.