In my reference, Page 26, Algorithms by Sanjoy Dasgupta, Christos H. Papadimitriou, and Umesh V. Vazirani, a division algorithm is give as, \begin{align} &\text{function divide}(x, y)\\\\ &\text{Input: Two n-bit integers x and y, where }y ≥ 1\\\\ &\text{Output: The quotient and remainder of x divided by y}\\\\ \\\\ &\text{if $x = 0$: return $(q, r) = (0, 0)$}\\\\ &\text{$(q, r)$ = divide$(\lfloor x/2\rfloor, y)$}\\\\ &\text{$q = 2 · q, r = 2 · r$}\\\\ &\text{if $x$ is odd: $r = r + 1$}\\\\ &\text{if $r ≥ y: r = r − y, q = q + 1$}\\\\ &\text{return $(q, r)$}\\\\ \end{align}
I am trying to understand the internal mathematical working of this recursive algorithm for division.
There is a similar recursive algorithm for multiplication given in my reference,
\begin{align} &\text{function multiply $(x, y)$}\\\\ &\text{Input: Two n-bit integers $x$ and $y$, where $y≥0$}\\\\ &\text{Output: Their product}\\\\ \\\\ &\text{if $y = 0$: return $0$}\\\\ &\text{$z$ $=$ multiply$(x, by/2c)$}\\\\ &\text{if $y$ is even:}\\\\ &\quad\text{return $2z$}\\\\ &\text{else:}\\\\ &\quad\text{return $x + 2z$}\\\\ \end{align} The operation of the multiplication algorithm can be understood as follows: $$ x.y=\begin{cases} 2(x.\lfloor y/2\rfloor)\text{ if }y\text{ is even}\\\\x+2(x.\lfloor y/2\rfloor)\text{ if }y\text{ is even} \end{cases} $$ which can be verified as, \begin{align} y&=2n\implies 2(x.\lfloor y/2\rfloor)=2(x.\lfloor n\rfloor)=2xn=x.2n=xy\\\\ y&=2n+1\implies x+2(x.\lfloor y/2\rfloor)=x+2(x.\lfloor n+1/2\rfloor)=x+2xn=x(1+2n)=xy \end{align}
But is it possible to understand the given division algorithm in a similar way ?