The variables "a" and "b" alternate holding the previous remainders "r""k"−1 and "r""k"−2. Assume that "a" is larger than "b" at the beginning of an iteration; then "a" equals "r""k"−2, since "r""k"−2 > "r""k"−1. During the loop iteration, "a" is reduced by multiples of the previous remainder "b" until "a" is smaller than "b". Then "a" is the next remainder "r""k". Then "b" is reduced by multiples of "a" until it is again smaller than "a", giving the next remainder "r""k"+1, and so on.