Allowing swapping of subjects a and b depending on magnitude, also termination once the residue of a parts over b is equal to zero