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$?