Remark
The loop can be described rather conveniently in matrix form: The vector (a,b)T is replaced by M(a,b)T, where
Here, q is the quotient of division of a by b.