GCF and LCM Calculator
MathFind the GCF (HCF) and LCM of any two numbers instantly using prime factorisation. Shows step-by-step working and factor breakdown with exponent notation. Free online calculator.
GCF (HCF)
Greatest Common Factor / Highest Common Factor
LCM
Lowest Common Multiple
What is a GCF & LCM?
The GCF & LCM Calculator (also known as HCF and LCM Calculator in Indian school notation) computes both the Greatest Common Factor and the Least Common Multiple of any two positive integers simultaneously. It also displays the complete prime factorisation of each input as individual factor chips with exponents, and verifies the result using the identity GCF × LCM = a × b.
GCF (Greatest Common Factor) — also called HCF (Highest Common Factor) or GCD (Greatest Common Divisor) — is the largest integer that divides both numbers exactly. LCM (Least Common Multiple) is the smallest positive integer that is divisible by both numbers. While these are taught as separate topics in school, they are intimately related: for any two numbers a and b, GCF(a, b) × LCM(a, b) = a × b. This calculator exploits that relationship to compute both in a single pass using the efficient Euclidean algorithm for GCF, then derives LCM from it.
In Indian mathematics education, HCF and LCM are introduced in Classes 5–6 under the chapter "Playing with Numbers" and revisited in Class 10 (Real Numbers chapter) where the Euclidean algorithm and prime factorisation method are formalised. Beyond school, these concepts appear whenever you need to divide things into equal groups without leftovers (GCF), or find the first point where two periodic processes coincide (LCM).
The Prime Factorization Calculator is a natural companion to this tool — if you want a deep exploration of a single number's factor tree, that calculator gives you the full prime breakdown with divisor count and primality check.
How to use this GCF & LCM calculator
Enter Number A — type the first positive integer. Accepts whole numbers from 1 upwards. Negative numbers and decimals are not supported (GCF/LCM are defined for positive integers).
Enter Number B — type the second positive integer. The two numbers can be equal (in which case GCF = LCM = the number itself), or one can be a multiple of the other.
Read GCF — the primary result card shows the Greatest Common Factor. This is the answer to "what is the HCF of a and b?" in CBSE notation.
Read LCM — the secondary result card shows the Least Common Multiple. This is the answer to "what is the LCM of a and b?" and the answer to "when do these two periodic events first coincide?" type problems.
Examine Prime Factor Chips — the factor chips for each number show the complete prime factorisation. Identify which primes are shared and how the minimum/maximum exponent rule produces the GCF and LCM.
Verify GCF × LCM = a × b — the green verification card confirms both results are consistent and correct.
Formula & Methodology
Euclidean Algorithm (for GCF):GCF(a, b) = GCF(b, a mod b), repeating until remainder = 0Last non-zero remainder = GCF LCM from GCF:LCM(a, b) = (a × b) / GCF(a, b) Prime Factorisation method (alternative):GCF = product of common primes, each to the minimum exponentLCM = product of all primes, each to the maximum exponent Verification identity:GCF(a, b) × LCM(a, b) = a × b Worked example — CBSE Class 10 style problem: Find the HCF and LCM of 252 and 360 using the prime factorisation method. Step 1 — Factorise both numbers:252 = 2² × 3² × 7360 = 2³ × 3² × 5 Step 2 — HCF (minimum exponents of common primes):Common primes: 2 (min of 2 and 3 = 2) and 3 (min of 2 and 2 = 2)HCF = 2² × 3² = 4 × 9 = 36 Step 3 — LCM (maximum exponents of all primes):All primes: 2 (max = 3), 3 (max = 2), 5 (max = 1), 7 (max = 1)LCM = 2³ × 3² × 5 × 7 = 8 × 9 × 5 × 7 = 2,520 Step 4 — Verify: HCF × LCM = 36 × 2,520 = 90,720 = 252 × 360 = 90,720 ✓ Assumption: GCF and LCM are defined for positive integers only. Entering 0 is treated as undefined (most implementations return the other number for GCF(0, n) = n by convention, but this calculator requires both inputs to be positive integers ≥ 1).