Consider a sequence $a_i=p \mod a_{i-1}$, where $p$ is a prime number, how to estimate the smallest $i$ where $a_i=1$? Given a prime number $p$ and an integer $0<a_0<p$. Consider a sequence $a_i=p \mod a_{i-1}$. How to estimate the smallest $i$ where $a_i=1$? 
I tried some prime numbers, and found that such $i$ is always small. I have never found an $i$ larger than 50 when $p$ is smaller than $10^7$. How to estimate the upper bound of $i$?
 A: This is a long comment rather than an answer.
Let $p$ be a prime. Consider the map $f(a)$ which assigns to $0<a<p$ the remainder of $p$ modulo $a$. The questions asks when the sequence $a$, $f(a)$, $f(f(a))$,... reaches $1$ for a starting $1<a<p$. Let $I(p)$ be the length of the longest such sequence as $a$ varies in $1<a<p$. The question asks for an upper bound on $I(p)$.
In average, we expect that $f(a)$ is half of $a$. So we should expect sort of $\log_2(p)$ steps in $a$, $f(a)$, $f(f(a))$, ... to reach $1$.
We can look at it the other way. What are the $a$ such that $f(a)=b$? Any such $a$ will be a divisor of $p-b$. Now we build a tree with root $1$. The branches to $1$ are all divisors of $p-1$ except $1$. Repeatedly, we put above any $b$ so far added to the tree all the divisors of $p-b$ which did not yet appear. The length of the longest path from the root is $I(p)$.
Since there are at most $\log_2(p)$ branches above each number, one gets (if I got that right) that $I(p)> C \log(p)/\log\log(p)$. On the other hand we expect less than $\log(p)$ branches in average, that would again confirm that $I(p)$ might be bounded by something like $O(\log(p))$. But I am not certain; it might be larger. Most likely though the averge of $I(p)$ is logarithmic in $p$.
This also illustrates that primes $p$ where $\tfrac{p-1}{2}$ is a Sophie Germain prime are likely to have a larger $I(p)$ while $p$ where $p-1$ has many factors should have smaller $I(p)$.
