← All Tools
GCD LCM Calculator🔒 100% local
Greatest common divisor/least common multiple. Privacy-first, no server uploads, no tracking.
Related Tools
Takes two or more integers separated by commas or spaces and prints their greatest common divisor and least common multiple. It also factorises every input and both results into primes, then compares GCD x LCM with the product of the inputs as a check. Euclid's algorithm and the trial-division factorisation run in the page's own JavaScript.
How to use it
- Type the integers, for example 12, 18 or 8 12 20.
- Press Process.
- Read GCD and LCM on the top lines, then use the factorisations underneath to see why those values came out as they did.
Worked example
12, 18becomesInput: 12, 18
GCD: 6
LCM: 36
Verification: 12 = 2 × 2 × 3
18 = 2 × 3 × 3
GCD factorization: 2 × 3
LCM factorization: 2 × 2 × 3 × 3
Check: GCD × LCM = 6 × 36 = 216
Product of inputs = 216 ✓ (matches: GCD × LCM = a × b for 2 numbers)8, 12, 20becomesInput: 8, 12, 20
GCD: 4
LCM: 120
Verification: 8 = 2 × 2 × 2
12 = 2 × 2 × 3
20 = 2 × 2 × 5
GCD factorization: 2 × 2
LCM factorization: 2 × 2 × 2 × 3 × 5
Check: GCD × LCM = 4 × 120 = 480
Product of inputs = 1920The checkmark line only appears when exactly two numbers are given, because the identity GCD x LCM = a x b does not hold for three inputs.
When to use it
- Finding a common denominator for fraction arithmetic, such as adding 3/8 and 5/12.
- Working out when two repeating cycles line up again (a 12-minute and an 18-minute job coincide every 36 minutes).
- Checking a spreadsheet or a homework answer against a second implementation, with the prime factorisation shown as evidence.
What it does not do
- Zero is rejected outright, and negative integers are accepted but their signs are discarded by the absolute-value step.
- Values are handled as JavaScript doubles, so the factorisation and the product line lose accuracy once you go past 2^53.
- Factorisation is trial division up to the square root: instant for everyday numbers, but a value with very large prime factors will stall the tab.