HomeCalculatorsMathGCF and LCM Calculator

GCF and LCM Calculator

Math

Find the GCF (HCF) and LCM of any two numbers instantly using prime factorisation, with step-by-step working and factor breakdown shown in full.

Reviewed by the thecalcu.com team · Last updated July 19, 2026

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.

Why Use a GCF & LCM Calculator?

For small numbers (under 20), GCF and LCM are easy to compute mentally or by listing factors. For larger numbers like 252 and 360, listing all factors becomes error-prone and slow. The Euclidean algorithm is efficient but requires careful tracking of remainders across several division steps. A single arithmetic slip produces a wrong GCF, which then cascades into a wrong LCM.

This calculator eliminates that arithmetic burden and adds two important extras. First, the prime factorisation chips let you see why the GCF and LCM have the values they do, the GCF is built from shared prime factors (minimum exponents), and the LCM from all prime factors (maximum exponents). This makes the result educationally meaningful rather than just a number. Second, the verification check GCF × LCM = a × b gives immediate confirmation that both results are correct and consistent.

For Class 10 CBSE students, this is particularly useful for the type of problem that gives GCF and LCM and asks for the original numbers, the relationship GCF × LCM = a × b plus the constraint a/GCF and b/GCF are coprime are the key tools.

Who Should Use This Calculator?

Class 5–6 students learning HCF and LCM for the first time. Seeing the prime factor chips alongside the HCF and LCM makes the prime factorisation method visual and easier to understand than a text-only explanation.

Class 10 students preparing for CBSE board examinations where the Real Numbers chapter requires GCF and LCM calculations using the Euclidean algorithm. Quick verification of multi-step division sequences prevents careless errors.

Engineering and competitive exam aspirants (JEE Foundation, CAT, GMAT) where HCF-LCM problems in word-problem form are common. Problems like "two tasks complete in X and Y minutes, when do they coincide?" translate directly to LCM calculations.

Teachers and tutors who want to explain the prime factorisation method visually. The factor chips showing 2³ × 3² × 5 for each number make it easy to identify common factors and pick minimum/maximum exponents.

Software developers who need to compute GCD for implementing modular arithmetic, cryptographic algorithms (RSA key generation uses GCD), or fraction simplification in number-parsing code. The Prime Factorization Calculator is a complementary tool for deeper number theory needs.

What Insights Does the GCF & LCM Calculator Give You?

GCF (HCF), the primary result. This is the largest number that divides both inputs with zero remainder. A GCF of 1 means the two numbers are coprime (no common factors other than 1), for example, GCF(7, 13) = 1 since both are prime. A large GCF relative to the inputs means they share many factors, for example, GCF(48, 72) = 24, which means both numbers are divisible by 2, 3, and 4 among others.

LCM, the secondary result. This is the smallest number that both inputs divide into exactly. Large LCMs relative to the inputs indicate the numbers share few common factors. If LCM equals a × b, the GCF is 1 (the numbers are coprime).

Prime Factorisation Chips, each chip shows a prime base and its exponent (e.g., "2³", "5²") for both input numbers. To find GCF from the chips: take each prime that appears in both numbers, use the lower exponent. To find LCM from the chips: take each prime that appears in either number, use the higher exponent.

Verification: GCF × LCM = a × b, displayed as a green confirmation card. This is a mathematical identity, not an approximation, if this equality holds, both GCF and LCM values are guaranteed to be correct. If you're computing by hand and get a GCF × LCM ≠ a × b, one of your intermediate steps contains an error.

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

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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Also known as
GCFLCMgreatest common factorleast common multipleHCFhighest common factorGCF LCM