This will be a frequent case. Suppose we want to find the 100th digit. We have the milestone set to 100. If we check digits<milestone, then this condition will be true for every case. But if it is what I have done, this condition will be true once the milestone is reached. And once we reach a particular milestone, we increase it.
I guess your condition will result in an infinite loop!