Note that $\frac{1}{3} = \frac{1}{4} + \frac{1}{16} + \frac{1}{64} + \frac{1}{256} + \cdots$ In fact, we have

This fact is useful in performing integer division. We can compute $m$ divided by $n$ by recursion (note the summation sign above). Consider $m/(n-1)$, we have

Since $A = m \textrm{ div } n$, $B = m \textrm{ mod } n$, if $n$ is a power of 2, we can perform the div and mod operations by bit shift.

def div(m, n):
# n+1 is 2^k assumed here
result = 0
A = m
while (True):
A = A >> k
B = A & n