Subtracting the smaller positive integer from the larger preserves their common divisors because an integer divides both a and b exactly when it divides both a and b−a. Consequently, the sets of common divisors, and hence the greatest common divisor (gcd), stay the same.
Conditions: a and b are positive integers.; b>a (so we subtract a from b).
Subtracting the smaller positive integer from the larger preserves their common divisors because an integer divides both a and b exactly when it divides both a and b−a. Consequently, the sets of common divisors, and hence the greatest common divisor (gcd), stay the same.
Conditions: a and b are positive integers.; b>a (so we subtract a from b).
The invariant property is that the set of common divisors of two numbers a and b is identical to the set of common divisors of a and b−a (or b and amodb). This ensures that the greatest common divisor (gcd) remains unchanged throughout the algorithm's steps.
Conditions: a and b are integers.; The operation is either subtraction (b−a) or modulo (amodb).
The invariant property is that the set of common divisors of two numbers a and b is identical to the set of common divisors of a and b−a (or b and amodb). This ensures that the greatest common divisor (gcd) remains unchanged throughout the algorithm's steps.
Conditions: a and b are integers.; The operation is either subtraction (b−a) or modulo (amodb).