HomeCalculatorsMathGCF and LCM Calculator

GCF and LCM Calculator

Math

Find 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.

First Number
Second Number

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

  1. 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).

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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).
Frequently Asked Questions
What is the difference between GCF and LCM?
GCF (Greatest Common Factor), also called GCD (Greatest Common Divisor), is the largest positive integer that divides both numbers without leaving a remainder. LCM (Least Common Multiple) is the smallest positive integer that is divisible by both numbers. For 12 and 18, GCF = 6 and LCM = 36. GCF is used for simplifying fractions and dividing into equal groups; LCM is used for finding common denominators and scheduling problems.
How do you find the GCF (HCF) of two numbers?
The most efficient method is the Euclidean algorithm: divide the larger number by the smaller, take the remainder, then replace the larger number with the smaller and the smaller with the remainder, repeating until the remainder is zero. The last non-zero remainder is the GCF. For 48 and 36: 48÷36 = 1 remainder 12; 36÷12 = 3 remainder 0. So GCF = 12. This is what our calculator uses internally.
How do you find the LCM of two numbers?
The simplest formula is LCM(a, b) = (a × b) / GCF(a, b). Once you have the GCF, multiply the two numbers and divide by the GCF. For 12 and 18: GCF = 6, so LCM = (12 × 18) / 6 = 216 / 6 = 36. Alternatively, find the prime factorisation of both numbers and take the highest power of each prime factor that appears — this is what the factor chips display in our calculator.
What is HCF and is it the same as GCF?
Yes — HCF (Highest Common Factor) and GCF (Greatest Common Factor) are exactly the same concept; GCD (Greatest Common Divisor) is another equivalent term. Indian school textbooks (NCERT) use 'HCF' while international and competitive exam contexts often use 'GCF' or 'GCD'. Our calculator displays it as GCF but the computed value is identical regardless of the name used.
What is the relationship between GCF and LCM?
For any two positive integers a and b, GCF(a, b) × LCM(a, b) = a × b. This identity is a quick verification check: if GCF = 6 and LCM = 36 for inputs 12 and 18, then 6 × 36 = 216 = 12 × 18 = 216 ✓. Our calculator always displays this verification so you can cross-check results instantly. The identity also lets you compute LCM from GCF without finding prime factors.
When is LCM used in real life?
LCM is used whenever events that repeat at different intervals need to coincide. For example, if one bus runs every 12 minutes and another every 18 minutes, they will both be at the stop simultaneously every LCM(12, 18) = 36 minutes. LCM is also used to find the common denominator when adding fractions with different denominators — to add ½ and ⅓, the LCD is LCM(2, 3) = 6, giving 3/6 + 2/6 = 5/6.
When is GCF (HCF) used in real life?
GCF is used whenever you need to divide items into equal groups of the largest possible size. For example, if you have 48 apples and 36 oranges to arrange in identical bags with no leftover, the maximum bag size is GCF(48, 36) = 12 — each bag gets 4 apples and 3 oranges. GCF is also used to simplify fractions to their lowest terms: 48/36 = (48/12)/(36/12) = 4/3.
What is the prime factorisation method for GCF and LCM?
Express each number as a product of prime factors. GCF is the product of primes common to both, each raised to the minimum exponent across the two numbers. LCM is the product of all primes that appear in either number, each raised to the maximum exponent. For 36 = 2²×3² and 48 = 2⁴×3¹: GCF = 2²×3¹ = 12; LCM = 2⁴×3² = 144. Our calculator displays the prime factorisation of each input as coloured chips.
Is HCF/LCM part of the CBSE syllabus?
Yes — HCF and LCM are first introduced in CBSE Class 5 and covered in detail in Class 6 (Chapter 3: Playing with Numbers). The Euclidean algorithm and prime factorisation methods are formalised in Class 10 (Chapter 1: Real Numbers). HCF and LCM also appear in the CBSE Class 10 board examination as direct-calculation or application-type questions. For NTSE, Olympiads, and competitive exams, problems involving LCM and HCF in word-problem form are common.
Can GCF and LCM be computed for more than two numbers?
Yes — for three or more numbers, compute GCF (or LCM) pairwise. For GCF(a, b, c) = GCF(GCF(a, b), c). For LCM(a, b, c) = LCM(LCM(a, b), c). Our calculator currently handles exactly two numbers at a time. To find GCF or LCM of three numbers, compute the result for the first two, then feed that result and the third number back into the calculator as a second pass.
What is the GCF if one number is a multiple of the other?
If b is a multiple of a (i.e. a divides b exactly), then GCF(a, b) = a. For example, GCF(6, 18) = 6 because 18 = 6 × 3 and 6 divides 18 with no remainder. Correspondingly, LCM(6, 18) = 18. This is a quick mental-check shortcut: whenever one of your two numbers divides the other, the GCF is simply the smaller number and the LCM is the larger number.