GCD and LCM
E · easyP · Verified PYQmath
Problem
Find the GCD (Greatest Common Divisor) and LCM (Least Common Multiple) of two numbers.
Example
Input
12 18
Output
GCD: 6 LCM: 36
Use Euclidean algorithm for GCD: gcd(a,b) = gcd(b, a%b). LCM = (a\*b) / gcd(a,b).