GCD and LCM
Greatest common divisor via Euclid's algorithm; $\text{lcm}(a,b) = a/\gcd(a,b)\cdot b$.
Beginner
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.