You can think about the long division algorithm as a bunch of if-else statements. For example, let's say you are dividing $\frac{B}{A}$ where $B$ is some string of digits $\overline{abcd....}$. The long division algorithm for the first digit of the quotient can be thought of as follows:
for digits in B:
\\as digits loops through B, one digit is added at every iteration
\\digits_1 = a, digits_2 = ab, digits_3 = abc, etc.
if (digits >= A):
C = digits
stop loop
Here, for example, if we have $\frac{782458}{984}$, we will get $C = 7824$.
Next, we can do the following:
for i from 1 to 9:
if (A * i <= C):
print(1)
else:
print(0)
digit_in_quotient = \\last i for which 1 was printed
So, essentially, we are individually testing each digit from $1$ to $9$ to see which one maximises $C - A\cdot i$ given that this difference must be positive.
Now, the crucial part.
There are $2$ cases.
Case $1$: $C$ and $A$ have the same number of digits. In this case, $i$ must be necessarily less than $10$ as $A \cdot 10$ would have an extra digit.
Case $2$: $C$ has $1$ more digit than $A$. In this case, the leading digit of $A$ must be necessarily bigger than $C$ as otherwise, $C$ would have the same digits as $A$. As in case $1$, $i$ must be necessarily less than $10$ as otherwise $A \cdot i > C$ (since the leading digit of $A > $ leading digit of $C$).
As we have seen, in either case, a single-digit will suffice.
This algorithm can now be applied again to find the second digit of the quotient and so on with new values of $C$. Similarly, $A \cdot 10$ will always be greater than $C$. Hence, a digit greater than or equal to $10$ never goes in the quotient.
Edit: In case you didn't realize, the reason $A \cdot i$ cannot be greater than $C$ is because $C - A \cdot i$ would then be negative which is not a possibility in the long division algorithm.