Skip to content
UPEEC

GCD and LCM

Greatest common divisor via Euclid's algorithm; $\text{lcm}(a,b) = a/\gcd(a,b)\cdot b$.

Beginner
Comments 0
def gcd(a, b):
    while b: a, b = b, a % b
    return a

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.