GCF & LCM Calculator
Find the greatest common factor and least common multiple of two integers.
Calculations run on your device. Nothing is uploaded.
How to use this calculator
Enter two whole numbers and press Calculate. You get the greatest common factor, the least common multiple, the prime factorisations and the division steps behind them.
How the calculation works
The GCF is the largest positive number that divides both inputs without a remainder. The LCM is the smallest positive number that is a multiple of both. The calculator finds the GCF with repeated remainders, then uses LCM = (first number ÷ GCF) × second number. The prime factorisations make the same relationship visible: the GCF uses the shared primes at the lower power, and the LCM uses every prime from either number at the higher power. Their product always equals the product of the two inputs, so the result also checks GCF × LCM = a × b.
Worked examples
1. Find common factors and multiples
For 12 and 18, the greatest shared factor is 6. LCM = (12 ÷ 6) × 18 = 36, so 36 is the first positive number in both multiplication tables.
2. Compare coprime numbers
For 8 and 15, no factor above 1 divides both, so the GCF is 1. LCM = (8 ÷ 1) × 15 = 120.
Frequently asked questions
Are GCF, GCD, and HCF the same thing?
Yes. Greatest common factor, greatest common divisor, and highest common factor name the same positive number.
How does the LCM help with fractions?
The LCM of two denominators is their least common denominator. For denominators 12 and 18, use 36 to rewrite both fractions before adding or subtracting.
Can I use decimals or zero?
No. This calculator requires nonzero safe integers. Negative inputs are accepted as absolute values, so −12 and 18 give the same results as 12 and 18.
Why do large inputs sometimes show an error?
Even safe integer inputs can produce an LCM outside JavaScript’s exact integer range. The calculator rejects that result rather than claiming an exact rounded number.
Keep learning with related tools
Use Prime Factorization to see the prime building blocks of each number, or the Fraction Calculator to apply common factors and denominators. The integers lesson builds the underlying number skills. Related tools: Prime Factorization Calculator, Fraction Calculator. Read the Integers & Negative Numbers lesson or practice integers & negative numbers to build confidence without relying on a calculator.