Worked example

Data: 48 18
48 = 2 × 18 + 12
18 = 1 × 12 + 6
12 = 2 × 6
48 × 18 ÷ 6 = 144

→ GCD = 6; LCM = 144

Method and scope

Enter 2–100 integers, at most 100 digits each. Negative inputs use their absolute value. gcd(0,0)=0 by convention; any zero makes the LCM zero. Euclid’s algorithm gives exact integer results.

gcd(a,b)=gcd(b,a mod b); lcm(a,b)=|a/gcd(a,b) × b|

Sources