Take a prime number $P \ge 3$ and some integer $x \in [1, P-1]$. Let's consider a sequence of values $x = x_0, x_1, \ldots, x_k = 1$, where $x_{n+1} = P \bmod x_n$ and the first occurence of $1$ happens after $k$ iterations.
Are there any good lower bounds for such $k$? Since $x_{n+1} < x_n$, it is obviously $O(x)$. Exactly $x$ iterations can be reached using prime of form $P = k x! - 1$.
I tried some random values of $P$ up to $2^{25}$ and the maximum value of $k$ did not exceed $2 \log_2 P$. Can you prove it is always $O(\log P)$ or are there counterexamples?