Suppose that $p$ is a prime number and $x_1$ is an integer in range $[1, p - 1]$. If $x_k \not = 1$, define $x_{k + 1} := p \!\!\! \mod \!\! x_k$. Clearly, $x_{k + 1} < x_k$ and $x_{k + 1} > 0$ (because $p$ is prime), so there exists some $n$ (depending on $x_1$) such that $x_n = 1$. Is it true that $n = O(\log p)$?
For reference, it is quite easy to prove that $n = O(\sqrt p)$. Let $q_i := [\frac{p}{x_i}]$, i. e. $p = q_i x_i + x_{i + 1}$ for every $i \in [1, n - 1]$. Because $q_i x_i + x_{i + 1} = p = q_{i + 1} x_{i + 1} + x_{i + 2}$ for $i \in [1, n - 2]$ and $x_i > x_{i + 1}, x_{i + 1} > x_{i + 2}$, $q_i$ is increasing. On the other hand, $x_i$ is decreasing. Also $q_i x_i < q_i x_i + x_{i + 1} < p$ for every $i \in [1, n - 1]$. Therefore $q_i < \sqrt{p}$ or $x_i < \sqrt{p}$ for each $i \in [1, n - 1]$. Because $q_i$ increases, there can be at most $[\sqrt{p}]$ $i$-s with $q_i < \sqrt{p}$. The same way there can be at most $[\sqrt{p}]$ $i$-s with $x_i < \sqrt{p}$. Therefore $n \leqslant 2[\sqrt{p}]$.
Some ideas:
- Maybe it makes sense to think backwards: i. e. how long can a sequence $y$ be if $y_1 = 1$ and $y_{i + 1}$ is some divisor of $p - y_i$ that is bigger than $y_i$ (in this notation $x_i = y_{n + 1 - i}$)?
- One more way to look at this is to notice that the question asks to estimate how deep can a rooted tree on $p - 1$ vertices be, with root in $1$ and edges between $x$ and $p \!\!\! \mod \!\! x$ for $x = 2, 3, \ldots, p - 1$. Maybe it is possible to prove that this tree is somewhat balanced?
- Two heuristics suggest that the number of steps is indeed $O(\log p)$: first one assumes that $p \!\!\! \mod \!\! x$ is a random integer number in range $[1, x - 1]$ and second one uses "backwards" point of view and assumes that $p - y_i$ is divisible by $t$ with probability $t^{-1}$. Of course, both heuristics don't make too much sense, but they show that $n = O(\log p)$ is at least a reasonable enough statement to consider.
In fact, any ideas on proving any bound better than $O(\sqrt{p})$ are appreciated.