Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Let $n$ be a fixed positive integer. Define the function $f_n(x)$ as follows:
$$f_n(x)=\left\{\begin{aligned}&2x-1,\quad x\leq n;\\&2(x-n),\quad x> n.\end{aligned}\right.$$
and for $l\in\mathbb{N}^*$, $f_n^{(1)}(x)=f_n(x)$,
$f_n^{(l)}(x)=f_n(f_n^{(l-1)}(x))$.
My question is: Is there must be a $k\in\mathbb{N}^*$ such that $f_n^{(k)}(2)=2$? If the answer is yes, what's the relation between $k$ and $n$?
The set $\{2,3,\ldots,2n-1\}$ is mapped to itself, and if we use the new variable $y=x-1$, then it is doubled modulo $2n-1$. Thus the minimal $k$ is the multiplicative order of 2 modulo $2n-1$.