Calculators
GCD & LCM Calculator
Calculate GCD and LCM for two whole numbers.
Greatest common divisor (GCD)
6
Least common multiple (LCM)
144
About This Tool
Find two closely related number properties in one calculation. The greatest common divisor (GCD), also called the greatest common factor (GCF) or highest common factor (HCF), is the largest positive integer that divides both values without a remainder. The least common multiple (LCM) is the smallest non-negative multiple shared by both values. This is useful for simplifying ratios and fractions, grouping items evenly, and finding when repeating integer intervals align.
How To Use It
- Enter two whole numbers. Positive, negative, and zero values are supported.
- Read the GCD and LCM results calculated from the absolute values of the inputs.
- Copy either result when you need it in another calculation.
Examples
48 and 18
The GCD is 6 because 6 is the largest integer dividing both numbers. Their LCM is 144.
8 and 15
These numbers are coprime, so their GCD is 1. Their LCM is 120.
24 and 0
Using the standard integer convention, gcd(24, 0) is 24 and lcm(24, 0) is 0.
Useful Notes
How the GCD is found
The calculator uses the Euclidean algorithm: repeatedly replace the larger pair with the divisor and remainder until the remainder becomes zero. The last non-zero divisor is the GCD.
How the LCM is found
For non-zero integers a and b, LCM = |a / GCD(a,b) × b|. Dividing before multiplying reduces unnecessary intermediate growth. If either input is zero, the LCM is defined here as zero.
Signs and exact integer limits
GCD and LCM are reported as non-negative values, so negative inputs are treated by absolute value. Inputs and the resulting LCM must remain within JavaScript's safe-integer range so the tool does not present rounded integers as exact.
GCD, GCF, and HCF
Greatest common divisor, greatest common factor, and highest common factor are common names for the same integer concept. This page keeps them together instead of creating separate keyword-variant tools.
FAQ
What is the difference between GCD and LCM?
GCD looks for the largest integer that divides both numbers. LCM looks for the smallest non-negative number that is a multiple of both.
What if the GCD is 1?
The two integers are coprime: they have no positive common divisor larger than 1.
Can I enter negative numbers?
Yes. Divisibility for GCD and LCM depends on magnitude, so the calculator uses absolute values and returns non-negative results.
What happens when both numbers are zero?
This calculator uses gcd(0,0) = 0 and lcm(0,0) = 0 as a practical computational convention, and shows the zero behavior explicitly rather than dividing by zero.
Related Tools
Basic Calculator
PopularA simple arithmetic calculator for quick results.
Percentage Calculator
PopularFind percentages, percent change, increases, and decreases.
Roman Numeral Converter
Convert between decimal numbers and standard Roman numerals.
Number Base Converter
Convert integers between binary, octal, decimal, and hexadecimal.