How they are computed
GCD is found with the Euclidean algorithm: repeatedly replace the larger number with the remainder of dividing the two, until the remainder is zero — the last non-zero value is the GCD. LCM is then derived cheaply from it: LCM(a, b) = |a × b| ÷ GCD(a, b). This avoids factorising the numbers, which is why it stays fast even for large inputs.