Adjust the order so that m & gt=n
spread
m = m % n; If m=0, then n is the greatest common divisor and jumps out of the loop. Note:% means remainder operation.
n = n % m; If n=0, then m is the greatest common divisor and jumps out of the loop.
then
After finding the greatest common divisor g, find the least common multiple with m * n/g.