For integers $a,b$ we define $f((a,b))=(2a,b-a)$ if $a<b$ and $f((a,b))=(a-b,2b)$ if $a\geq b$.
Given a natural number $n>1$ show that there exist natural numbers $m,k$ with $m<n$ such that $f^{k}((n,m))=(m,n)$,where
$f^{k}(x)=f(f(f(...f(x))))$,$f$ being composed with itself $k$ times.
For $n$ even we clearly have $f(n,\frac{n}{2})= \frac{n}{2},n$ ......
For $n$ odd we have to adopt a different trick ......
Consider $2^s$ to be the lowest power of $2$ larger than $n$ ...
We show that $m = 2^s +1 -n$ and $k=s$ ...(eg if $n=19$, $s=5, 2^s=32$ and $m=14$)
Note that $m=2^s+1-n < n$ according to the definition of $2^s$. First note that sum invariance property .. if $ (a,b) = f(x ,y)$ then $a+b=x+y$.
We will show that for any positive $(x,y,t)$ such that $x+y=2^t+1$ we have $f(x,y) \equiv 2x, 2y \bmod (2^t+1) $
Proof: If $x<y$ then $f(x,y)=2x , y-x = 2x , 2y - (y+x) \equiv 2x, 2y \bmod (2^t +1) $ ...
Similarly if $x \geq y$ then $f(x,y)=x-y , 2y = 2x-(x+y) , 2y \equiv 2x, 2y \bmod (2^t +1) $ .
So we have
$f^s (m,n) \equiv 2^s m, 2^s n \bmod (2^s+1) \equiv -m, -n \bmod (2^s+1)\\
~~~~~~~~~~~~~\equiv 2^s+1-m,2^s+1-n \bmod (2^s+1) \equiv n,m \bmod (2^s+1) $
Due to the sum invariance property the neither component of $f^i(m,n)$ exceeds $2^s+1$ for any $i$ and so the modular equivalence becomes an equality.
QED
IMOTC 2014 Practice Test 2 Problem 3 wrote:
For integers $a,b$ we define $f((a,b))=(2a,b-a)$ if $a<b$ and $f((a,b))=(a-b,2b)$ if $a\geq b$.
Given a natural number $n>1$ show that there exist natural numbers $m,k$ with $m<n$ such that $f^{k}((n,m))=(m,n)$,where
$f^{k}(x)=f(f(f(...f(x))))$,$f$ being composed with itself $k$ times.
Consider the pairs of integers $(a,b)$ on the cartesian plane, without loss of generality we can assume that the domain of $f$ is ${\mathbb N}_0^2$, since the statement of the main problem only deals with non-negative integers.
Note that sum of the elements of a pair doesn't changes upon applying $f$ i.e. sum of the coordinates of points doesn't changes upon the application of $f,$ therefore, the image of the point $(m,n)$ would be on the line segment connecting $(0,m+n)$ and $(m+n,0).$ In the figure given below, the red dashed-line is the graph of $x,$ if the point $(m,n)$ is on the left side of the red dashed-line (inside the $1^{\text{st}}$ quadrant) then $m<n$ and if $(m,n)$ is on the right of the red dashed line or the red dashed-line (inside the $1^{\text{st}}$ quadrant) then $m\geqslant n.$ In the figure given below, $(m,n)$ is on the right side of the red dashed line, that means $(m,n)$ maps to $(m-n,2n).$ Observe that $(m-n,2n)$ is actually the reflection of $(m+n,0)$ upon $(m,n),$ similarly, when $(m,n)$ is on the other side of the red dashed line, $(m,n)$ is mapped to the reflection of $(0,m+n)$ upon $(m,n).$
[asy][asy] /* Geogebra to Asymptote conversion, documentation at artofproblemsolving.com/Wiki, go to User:Azjps/geogebra */import graph; size(16cm); real labelscalefactor = 0.5; /* changes label-to-point distance */pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */ pen dotstyle = black; /* point style */ real xmin = -11.121271624033312, xmax = 18.168646281975015, ymin = -8.151841046995846, ymax = 12.21934753123143; /* image dimensions */pen rvwvcq = rgb(0.08235294117647059,0.396078431372549,0.7529411764705882); pen dtsfsf = rgb(0.8274509803921568,0.1843137254901961,0.1843137254901961); pen wrwrwr = rgb(0.3803921568627451,0.3803921568627451,0.3803921568627451); /* draw figures */draw((xmin, 0*xmin-0.34)--(xmax, 0*xmax-0.34), linewidth(1.2) + rvwvcq); /* line */draw((-2.12,ymin)--(-2.12,ymax), linewidth(1.2) + rvwvcq); /* line */draw((-2.12,5.54)--(3.76,-0.34), linewidth(1.2)); draw((xmin, 1*xmin + 1.78)--(xmax, 1*xmax + 1.78), linewidth(1.2) + linetype("4 4") + dtsfsf); /* line */draw((1.43,1.99)--(1.43,-0.34), linewidth(1.2) + linetype("2 2") + wrwrwr); draw((0.82,2.6)--(0.82,-0.34), linewidth(1.2) + linetype("2 2") + wrwrwr); /* dots and labels */dot((-2.12,5.54),dotstyle); label("$(0,m+n)$", (-2.0251812016656734,5.783673527662117), NE * labelscalefactor); dot((-2.12,-0.34),linewidth(4pt) + dotstyle); label("$O(0,0)$", (-1.9238320047590702,-1.3107702558001189), NE * labelscalefactor); dot((3.76,-0.34),linewidth(4pt) + dotstyle); label("$L(m+n,0)$", (3.8530722189173128,-0.14525449137418012), NE * labelscalefactor); dot((1.43,1.99),dotstyle); label("$(m,n)$", (1.5220406900654389,2.2364516359309987), NE * labelscalefactor); dot((1.43,-0.34),linewidth(4pt) + dotstyle); label("$P(m,0)$", (1.5980525877453913,-1.3614448542534205), NE * labelscalefactor); dot((0.82,2.6),linewidth(4pt) + dotstyle); label("$M$", (0.9139455086258196,2.7938722189173175), NE * labelscalefactor); dot((0.82,-0.34),linewidth(4pt) + dotstyle); label("$\Psi(M)$", (-0.22623295657346654,-1.589480547293278), NE * labelscalefactor); clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); /* end of picture */[/asy][/asy]
Define $\Psi(a,b)=(a,0)$ for all points $(a,b)$ on the line segment connecting $(0,m+n)$ and $(m+n,0),$ where the co-domain of $\Psi$ is the segment connecting $(0,0)$ and $(m+n,0).$ Clearly, $\Psi$ is a bijection. Observe that operations of $f$ are preserved under $\Psi,$ i.e. the way $f$ behaves on the line segment connecting $(0,m+n)$ and $(m+n,0)$ is preserved on the line segment joining $O$ and $(m+n,0)$, precisely, if $\Psi(m,n)=(m,0)$ is on the right of $\Psi(M)$ (midpoint) then the image of $(m,n)$ under $\Psi$ is the reflection of $(m+n,0)$ upon $(m,0)$ and similar if $(m,0)$ is on the left of the midpoint.
Therefore the problem can be restated as follows:
Quote:
Let $OL$ be a line segment of length $m+n$ where $m<n,n>1,m,n\in\mathbb N$ with it's midpoint $\Psi(M).$ An operation consists of reflecting $L$ upon $P$ if $P$ is on $\Psi(M)L,$ otherwise reflecting $O$ upon $P,$ in either case we say the reflection, the image of $P$ under the operation, here $P$ is a point on $OL$ such that $PL=n.$ Prove that, given any $n>1$ we can choose $m<n$ such that after finite operations, $P$ again returns to it's starting place.
Now, mark the point $O$ and mark the point $L$ as $m+n$ and mark any point in between as the distance between that point and $O,$ so now any integer $0\leq h\leq m+n$ denotes a point on the line segment. Note that $P$ will be marked $m.$ Define $g(j)$ to be the value of the point $j$ after one operation, clearly, if $j\leqslant \frac{m+n}2$ then $g(j)=2j=2j\pmod{m+n},$ otherwise if $j>\frac{m+n}2$ then $g(j)=(m+n)-2((m+n)-j)=2j-(m+n)=2j\pmod{m+n},$ where the modulos are completely reduced and kept non-negative. Hence $g(j)=2j\pmod{m+n}$ for any valid $j$, therefore, $g^i(j)=2^ij\pmod{m+n}.$
Case (i) $n$ is even
In this case we choose $m=1$ and $k=i=\phi(n+1),$ then
\[g^i(m)=g^{\phi(n+1)}(1)=2^{\phi(n+1)}\cdot 1\pmod{1+n}=1=m=g^0(m)\]Thus, choosing $(m,k)=(1,\phi(n+1))$ works when $n$ is even.
Case (i) $n$ is odd
In this case we choose $m=2$ and $k=i=\phi(n+2),$ then
\[g^i(m)=g^{\phi(n+2)}(2)=2^{\phi(n+2)}\cdot 2\pmod{2+n}=2=m=g^0(m)\]Thus, choosing $(m,k)=(2,\phi(n+2))$ works when $n$ is odd.
And we are done. $\blacksquare$