GCD & LCM Calculator — Step-by-Step Solutions
The GCD & LCM Calculator finds the Greatest Common Divisor and Least Common Multiple of two or more numbers. It uses the Euclidean algorithm and prime factorisation to compute results efficiently.
Enter your numbers and the calculator will show the GCD, LCM, prime factorisations, and step-by-step working. Useful for simplifying fractions, finding common denominators, and solving number theory problems.
Your calculations will appear here
How to Use the GCD & LCM Calculator
- Enter two or more positive integers in the input fields, separated by commas if using a single field.
- Click "Calculate" to find both the GCD and LCM instantly.
- Review the step-by-step working, which shows the Euclidean algorithm and prime factorisation for each number.
- Use the results to simplify fractions or find common denominators in further calculations.
Formula and Theory
The greatest common divisor (GCD) of two or more integers is the largest positive integer that divides each of them without leaving a remainder. It is also called the highest common factor (HCF). The Euclidean algorithm computes the GCD efficiently: GCD(a, b) = GCD(b, a mod b), repeated until the remainder is zero. The last non-zero remainder is the GCD.
The least common multiple (LCM) of two or more integers is the smallest positive integer that is divisible by each of them. The relationship between GCD and LCM is given by the formula: LCM(a, b) = |a * b| / GCD(a, b). This means you only need to compute the GCD to derive the LCM.
Prime factorisation provides an alternative method. The GCD takes the lowest power of each common prime factor, while the LCM takes the highest power of every prime factor present in any of the numbers. For example, 12 = 2^2 * 3 and 18 = 2 * 3^2, so GCD = 2 * 3 = 6 and LCM = 2^2 * 3^2 = 36.
Worked Examples
Example 1: GCD using the Euclidean algorithm
Problem: Find the GCD of 48 and 18.
Solution: GCD(48, 18): 48 = 2 * 18 + 12. GCD(18, 12): 18 = 1 * 12 + 6. GCD(12, 6): 12 = 2 * 6 + 0. The last non-zero remainder is 6.
Answer: GCD(48, 18) = 6
Example 2: LCM from GCD
Problem: Find the LCM of 12 and 8.
Solution: First find GCD(12, 8) = 4. Then LCM = (12 * 8) / 4 = 96 / 4 = 24.
Answer: LCM(12, 8) = 24
Example 3: GCD of three numbers
Problem: Find the GCD of 24, 36, and 60.
Solution: GCD(24, 36) = 12. Then GCD(12, 60) = 12.
Answer: GCD(24, 36, 60) = 12
Example 4: Real-world application: simplifying a recipe ratio
Problem: A recipe calls for 150g flour and 225g sugar. Simplify the ratio.
Solution: Find GCD(150, 225). 225 = 1 * 150 + 75. 150 = 2 * 75 + 0. GCD = 75. Divide both: 150/75 = 2, 225/75 = 3.
Answer: The ratio simplifies to 2:3
Frequently Asked Questions
What is the difference between GCD and LCM?
Why is the GCD useful for simplifying fractions?
What is the Euclidean algorithm?
Can I find the GCD of more than two numbers?
When would I use the LCM in everyday life?
Related General Calculators
Percentage Calculator
Calculate percentages instantly. Find what percent of a number, percentage change, and percentage difference. Free and fast.
Fraction Calculator
Add, subtract, multiply, and divide fractions. Simplify fractions and convert to mixed numbers. Free online fraction calculator.
Ratio Calculator
Simplify ratios and find missing values in proportions. Free online ratio calculator with step-by-step results.
Exponent Calculator
Calculate powers and exponents instantly. Compute base raised to any power including negative and fractional exponents. Free online tool.
Log Calculator
Calculate logarithms with any base. Find natural log (ln), log base 10, and custom base logarithms. Free online log calculator.
Factor Calculator
Find all factors, prime factorisation, factor pairs, GCD, and LCM. Free online factor calculator with instant results.