3 ms·
A variant is useful to update two (or more) dependent variables in one go without having to introduce temporary variables. For example to calculate the greatest
by roelschroeven 3y ago
A variant is useful to update two (or more) dependent variables in one go without having to introduce temporary variables. For example to calculate the greatest common divisor using the Euclidean algorithm:
def gcd(a, b):
while b > 0:
a, b = b, a % b
return a