GCD / LCM Calculator
Find the greatest common divisor and least common multiple of two numbers.
How to Use the GCD & LCM Calculator
This free online calculator finds the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of any two integers instantly. Follow these simple steps:
- Enter two numbers — type any whole numbers into the "First Number" and "Second Number" fields. Negative numbers and zero are accepted.
- Click Calculate — or press Enter. The GCD and LCM appear immediately.
- Review the steps — the tool displays every step of the Euclidean algorithm so you can follow the division process that leads to the GCD.
- See the LCM formula — the calculator shows how LCM is derived from GCD using the relationship LCM(a, b) = |a × b| / GCD(a, b).
All calculations run entirely in your browser. No data is sent to any server, and no sign-up is required.
What Is the GCD?
The Greatest Common Divisor (also called the Highest Common Factor) is the largest positive integer that divides both numbers without a remainder. For example, GCD(48, 18) = 6 because 6 is the biggest number that divides both 48 and 18 evenly.
What Is the LCM?
The Least Common Multiple is the smallest positive integer that is divisible by both numbers. For example, LCM(4, 6) = 12 because 12 is the smallest number that both 4 and 6 divide into evenly.
The Euclidean Algorithm
This tool uses the Euclidean algorithm, one of the oldest known algorithms, to compute the GCD. It works by repeatedly dividing the larger number by the smaller and replacing the larger with the remainder until the remainder is zero. The last non-zero remainder is the GCD.
Frequently Asked Questions
What is the difference between GCD and LCM?
The GCD (Greatest Common Divisor) is the largest number that divides two integers exactly, while the LCM (Least Common Multiple) is the smallest number that both integers divide into. They are related by the formula: GCD(a, b) × LCM(a, b) = |a × b|.
How does the Euclidean algorithm work?
The Euclidean algorithm finds the GCD by repeatedly dividing the larger number by the smaller and replacing the pair with (smaller, remainder). When the remainder reaches zero, the last non-zero remainder is the GCD. For example, GCD(48, 18): 48 = 18×2 + 12, then 18 = 12×1 + 6, then 12 = 6×2 + 0 — so GCD is 6.
What happens when one of the numbers is zero?
GCD(a, 0) = |a| for any integer a, because every integer divides zero. The LCM of any number and zero is defined as 0.
Can I use negative numbers?
Yes. The calculator takes the absolute value of each input before computing. GCD and LCM are always returned as non-negative values, so GCD(-12, 8) = 4 and LCM(-12, 8) = 24.
Where are GCD and LCM used in real life?
GCD is used to simplify fractions (divide numerator and denominator by their GCD). LCM is used to find common denominators when adding fractions, to schedule recurring events, and in music to find when rhythmic patterns align. Both are fundamental in cryptography and computer science algorithms.
More Math & Calculators
Percentage Calculator
Calculate percentages: X% of Y, percentage increase/decrease, and more.
Open tool →Age Calculator
Calculate exact age in years, months and days from a birthdate.
Open tool →BMI Calculator
Calculate your Body Mass Index and find your weight category.
Open tool →Tip Calculator
Calculate tip amount and split the bill between friends.
Open tool →Discount Calculator
Calculate discount amount, final price and savings instantly.
Open tool →Loan / Mortgage Calculator
Calculate monthly payments, total interest and amortization for any loan.
Open tool →