Starting with an ordered quadruple of positive integers, a generalized Euclidean algorithm is applied successively as follows: if the numbers are $x, y, u, v$ and $x > y,$ then the quadruple is replaced by $x − y, y, u + v, v.$ Otherwise, it is replaced by $x, y − x, u, v + u.$
The algorithm stops when the numbers in the first pair become equal (in which case they are equal to the greatest common divisor of x and y). Assume that we start with $m, n, m, n.$ Prove that when the algorithm ends, the arithmetic mean of the numbers in the second pair equals the least common multiple of $m$ and $n.$
The quantity $I = xv+yu$ does not change under the operation, so it remains equal to $2mn$ throughout the algorithm. When the first two numbers are both equal to $\gcd(m, n),$ the sum of the latter two is $ \frac{2mn}{\gcd(m,n)} = 2\operatorname{lcm}(m, n)$.
(St. Petersburg City Mathematical Olympiad, 1996)
Can you please explain why the sum of the latter two is $ \frac{2mn}{\gcd(m,n)} = 2\operatorname{lcm}(m, n)$. Also, a link to similar problems is also welcome.
It is a theorem that $\operatorname{LCM}(m,n)\operatorname{GCD}(m,n)=mn$. To see this, consider the powers of a prime dividing $m,n$ The maximum is a factor of the $\operatorname{GCD}$, the minimum is a factor of the $\operatorname{LCM}$ so the powers on each side are equal.
To see the invariance, apply the rule. We assume $x \gt y$ and use primes for the new variable values $$x'v'+y'u'=(x-y)v+y(u+v)=xv+yu$$ The other case is similar