GCD and LCM calculator
Compute the greatest common divisor and least common multiple with Euclid’s remainder steps. Your inputs stay on your device.
Set up your task
Starting local processing
Ready. Processing stays in this browser.
2 Your result
Your result updates in this browser. Check your input if the result looks unexpected.
How to use GCD and LCM calculator
Compute the greatest common divisor and least common multiple with Euclid’s remainder steps. The pre-filled problem gives you a worked starting point. Compare the response with your own working before trying the self-check below.
- Check the example inputs: First integer, Second integer.
- Change the inputs for your problem. Results update as you type, so finish entering the values before copying an answer.
- Use the working to check an intermediate value or assumption. Then change the example as suggested in the self-check and compare the result.
Supported inputs and limits
Enter signed whole numbers of up to 40 digits. The outputs are non-negative and the least common multiple is zero if either input is zero.
How it works
The greatest common divisor is the largest positive integer that divides both nonzero inputs, with the usual zero cases handled by absolute value. The least common multiple is the first positive multiple they share when neither input is zero. These numbers help reduce fractions and synchronise periodic events.
Euclid’s algorithm replaces a pair by the divisor and the remainder. Common divisors of the old pair are exactly the common divisors of the new one. When the remainder becomes zero, the last nonzero value supplies the greatest common divisor. Dividing before multiplying makes the LCM formula useful with large integers.
Example
Run the pre-filled example. Its first result is “GCD: 6 · LCM: 420”.
- First integer
- 84
- Second integer
- 30
GCD: 6 · LCM: 420 84 mod 30 = 24 30 mod 24 = 6 24 mod 6 = 0
Questions about GCD and LCM calculator
What happens for GCD(0, 0)?
The tool uses the common computational convention of returning zero. Every positive integer divides zero, so there is no largest positive common divisor in the literal order.
What does a GCD of 1 mean?
The numbers are coprime. They can still each be composite because coprimality refers only to shared factors.
Use first integer −18 and second integer 24.
Expect GCD 6 and LCM 72. The signs affect neither result because they do not change which positive integers divide the values.
Related tools
Last updated