Quick Answer
The GCD of 12 and 18 is 6, and the LCM of 12 and 18 is 36.
Separate values with commas, spaces, or newlines. Non-integer and zero values are ignored.
Common Examples
| Input | Result |
|---|---|
| 12, 18 | GCD: 6, LCM: 36 |
| 24, 36, 48 | GCD: 12, LCM: 144 |
| 7, 13 | GCD: 1, LCM: 91 |
| 100, 75, 50 | GCD: 25, LCM: 300 |
| 8, 12, 20 | GCD: 4, LCM: 120 |
How It Works
The Euclidean Algorithm (GCD)
The Euclidean algorithm is one of the oldest known algorithms, dating back to Euclid’s Elements (circa 300 BC). It finds the GCD of two numbers by repeatedly applying the division algorithm:
GCD(a, b): While b is not 0, replace (a, b) with (b, a mod b). When b = 0, a is the GCD.
For more than two numbers, apply the algorithm iteratively: GCD(a, b, c) = GCD(GCD(a, b), c).
Least Common Multiple (LCM)
The LCM is calculated using its relationship with the GCD:
| **LCM(a, b) = | a x b | / GCD(a, b)** |
For more than two numbers, apply the formula iteratively: LCM(a, b, c) = LCM(LCM(a, b), c).
Key Properties
For any two positive integers a and b:
- GCD(a, b) x LCM(a, b) = a x b
- GCD(a, b) always divides both a and b
- LCM(a, b) is always divisible by both a and b
- If GCD(a, b) = 1, the numbers are called coprime (or relatively prime)
Worked Example
To find GCD(24, 36):
- 36 = 1 x 24 + 12 (remainder 12)
- 24 = 2 x 12 + 0 (remainder 0)
- GCD = 12
| LCM(24, 36) = | 24 x 36 | / 12 = 864 / 12 = 72. |
| For three numbers, GCD(24, 36, 48): First GCD(24, 36) = 12, then GCD(12, 48) = 12. LCM(24, 36, 48): First LCM(24, 36) = 72, then LCM(72, 48). GCD(72, 48) = 24, so LCM = | 72 x 48 | / 24 = 3456 / 24 = 144. |
Related Calculators
Fraction Calculator
Add, subtract, multiply, and divide fractions. Simplify fractions and convert between fractions and decimals.
Ratio Calculator
Simplify ratios, solve proportions, and scale ratios up or down.
Standard Deviation Calculator
Calculate the standard deviation, variance, mean, and other statistics for any data set.
CalculateY