Mathematics
GCD and LCM calculator
Find the greatest common divisor and least common multiple of two or three positive whole numbers. See each prime factorisation.
Also available for Germany, in German
Also available for Poland, in Polish (dobrykalkulator.pl)
Enter a number as you would write it, for example 1,250, −2.5 or 1e3. Downloads keep your entries and results; nothing is stored or sent.
Result
Formula / calculation:
Enter positive whole numbers from 1 to 1,000,000,000 for A and B. Set C to 0 to use two numbers, or enter a positive whole number for a third. Results are exact integers; very large results are displayed without separators. The two-number identity does not apply to three numbers.
Decimal results are approximate. Inputs stay in this browser tab.
How it works
Euclid’s algorithm finds the GCD. The LCM uses a divided product before multiplication to keep the integer exact.
Worked example
For 48 and 18, GCD = 6 and LCM = 144; 6 × 144 = 48 × 18.
Worked example
With these example values the calculator gives the result below. You can change any value in the form above.
Inputs
- First number (A)
- 48
- Second number (B)
- 18
- Third number
- 0
Result
- Numbers
- 48, 18
- Greatest common divisor (GCD)
- 6
- Least common multiple (LCM)
- 144
- Prime factors of A
- 48 = 2^4 × 3
- Prime factors of B
- 18 = 2 × 3^2
- Two-number identity
- 6 × 144 = 864
Frequently asked questions
How do I find the GCD and LCM of two numbers?
Enter positive whole numbers for A and B, from 1 to 1,000,000,000. For 48 and 18, the GCD is 6 and the LCM is 144.
Can the GCD and LCM calculator use three numbers?
Yes. Enter a positive whole number for C. Setting C to 0 means two numbers are used.
Which method finds the greatest common divisor?
Euclid's algorithm finds the GCD. The LCM uses a divided product before multiplication to keep the integer exact.
Does the calculator show prime factorisation?
Yes. It shows the prime factors of each number, for example 48 = 2^4 × 3 and 18 = 2 × 3^2.
What is the identity between GCD and LCM?
For two numbers, gcd(a,b) × lcm(a,b) = a × b, for example 6 × 144 = 48 × 18. This two-number identity does not apply to three numbers.
Are the GCD and LCM results exact?
Yes. Results are exact integers, and very large results are displayed without separators.