Math & Number Theory

LCM & HCF Calculator

Find the Least Common Multiple (LCM) and Highest Common Factor (HCF / GCD) of 2, 3 or more numbers instantly. Full step-by-step working via Prime Factorisation, Division Method and Euclidean Algorithm.

Instant LCM & HCF
3 Solution Methods
Division Table Shown
100% Free
Updated April 2026
Before You Calculate

LCM and HCF — Why These Two Numbers Unlock Most of Arithmetic

April 2026  ·  4 min read  ·  Keeroot Solutions

The Least Common Multiple (LCM) and Highest Common Factor (HCF) — also called LCM and GCD (Greatest Common Divisor) in different curricula — are two of the most practically useful concepts in number theory. They appear in everything from adding fractions to writing software that synchronises repeating events, from scheduling maintenance intervals to cutting fabric into equal pieces without waste.

At their core, the relationship is elegantly simple: LCM(a, b) × HCF(a, b) = a × b for any two positive integers. This means if you know one, you can always find the other. But the applications of each are quite different — HCF is for dividing and simplifying; LCM is for combining and synchronising.

When to Use LCM vs When to Use HCF

Use HCF when you need to divide into equal groups. Distributing 24 apples and 36 oranges into identical bags (maximum bags, no leftovers): HCF(24, 36) = 12 bags, each with 2 apples and 3 oranges. Simplifying the fraction 36/48: HCF(36, 48) = 12, so 36/48 = 3/4. Finding the largest square tiles that fit exactly in a 360 cm × 540 cm floor without cutting: HCF(360, 540) = 180 cm tiles.

Use LCM when you need the earliest moment of synchronisation. Two buses leaving a terminus every 12 and 18 minutes respectively: next simultaneous departure in LCM(12, 18) = 36 minutes. Adding fractions: 1/6 + 1/4 requires the common denominator LCM(6, 4) = 12, giving 2/12 + 3/12 = 5/12. Events that repeat every 3 and 5 years coinciding: in LCM(3, 5) = 15 years. Also see our Fraction Calculator and GST Calculator.

The Three Methods This Calculator Uses

Prime Factorisation — factor each number into primes, then HCF takes minimum powers and LCM takes maximum powers. Best for understanding the structure, not for large numbers. Division Method — repeatedly divide all numbers by their common prime factors. Compact and easy to show in a table. Euclidean Algorithm — uses the identity GCD(a, b) = GCD(b, a mod b) repeatedly until the remainder is 0. The fastest method computationally and works for large numbers without needing prime factors.

🔢 Result Insight

LCM & HCF Calculator

Enter 2 to 6 numbers — get LCM, HCF, prime factorisations and step-by-step working in 3 methods

12 and 18
Classic pair
24, 36 and 48
Three numbers
7 and 13
Co-prime pair
56 and 98
Larger numbers
15, 25 and 35
Multiples of 5
Quick number pairs:
LCM & HCF RESULT
LCM = ?  |  HCF = ?
Solution Summary
All 3 Methods — Comparison
Prime Factor Breakdown
Division Method Table
Step-by-Step Working
    Share This Solution

    What Are LCM and HCF?

    Definitions, relationship, key properties and why these concepts appear everywhere in maths and daily life

    Two Fundamental Concepts in Number Theory

    The Highest Common Factor (HCF) — also called Greatest Common Divisor (GCD) or Greatest Common Factor (GCF) — is the largest positive integer that divides each of the given numbers without leaving a remainder. The HCF of 12 and 18 is 6 because 6 is the largest number that divides both exactly.

    The Least Common Multiple (LCM) is the smallest positive integer that is divisible by all of the given numbers. The LCM of 12 and 18 is 36 because 36 is the smallest number that both 12 and 18 divide into exactly. Every common multiple of the numbers is a multiple of the LCM.

    📌 Golden Relationship: For any two positive integers a and b — LCM(a, b) × HCF(a, b) = a × b. This means if you know any three of the four values, you can find the fourth instantly. Example: LCM(12,18) × HCF(12,18) = 36 × 6 = 216 = 12 × 18. ✓

    HCF and LCM are used in simplifying fractions (HCF to reduce, LCM to add/subtract), scheduling problems (when will two periodic events align?), gear ratios, tiling problems, music rhythm theory, and computer science (hash tables, memory alignment, and cyclic redundancy checks). They are among the oldest and most practically useful ideas in mathematics.

    🔢
    HCF — Highest Common Factor
    The largest divisor shared by all numbers. HCF(a,b) divides both a and b. HCF = 1 means the numbers are co-prime (no common factors except 1). Used to simplify fractions: 12/18 = (12÷6)/(18÷6) = 2/3.
    ♾️
    LCM — Least Common Multiple
    The smallest number divisible by all given numbers. Used to find common denominators: to add 1/12 + 1/18, use LCM = 36 as common denominator → 3/36 + 2/36 = 5/36. Every common multiple = k × LCM.
    🔍
    Co-prime Numbers
    Two numbers are co-prime (relatively prime) when HCF = 1. Examples: 7 and 13, 8 and 9, 25 and 36. Co-prime pairs have LCM = a × b. Consecutive integers are always co-prime. This is key in cryptography (RSA algorithm).
    🧮
    Prime Factorisation Link
    HCF = product of common prime factors with minimum powers. LCM = product of all prime factors with maximum powers. Example: 12 = 2²×3, 18 = 2×3². HCF = 2¹×3¹ = 6. LCM = 2²×3² = 36.

    Three Methods — When to Use Each

    Prime Factorisation, Division Method and Euclidean Algorithm compared with examples and use cases

    Pick the Right Tool for Each Problem
    MethodApproachBest WhenLimitation
    Prime Factorisation Most educationalExpress each number as product of primes; HCF = min powers, LCM = max powersNumbers up to ~200; teaching/learning; 3+ numbersSlow for large numbers; finding prime factors can be tedious
    Division Method (Ladder)Divide all numbers by common prime factors; HCF = product of divisors, LCM = product of all primes usedFinding LCM of 3+ numbers; exam problemsSlightly mechanical; easy to miss a prime factor
    Euclidean Algorithm Fastest for 2 numbersGCD(a,b) = GCD(b, a mod b) until remainder = 0; then LCM = a×b / HCFLarge numbers; two numbers; programmingOnly directly gives HCF of two numbers at a time
    Listing Multiples/FactorsList multiples of each number; LCM = first common multiple. List factors; HCF = largest commonSmall numbers; mental maths; beginnersImpractical for large numbers
    🔢
    Prime Factorisation Worked

    12 = 2² × 3, 18 = 2 × 3². Common primes: 2 (min power 1) and 3 (min power 1). HCF = 2¹ × 3¹ = 6. All primes: 2 (max power 2) and 3 (max power 2). LCM = 2² × 3² = 36. Check: 6 × 36 = 216 = 12 × 18. ✓

    Step by step
    ÷
    Division Method Worked

    Write 12 and 18 in a row. Divide by smallest prime that divides at least one: 2→6,9; 2→3,9; 3→1,3; 3→1,1. HCF = product of primes that divided ALL numbers = 2×3 = 6. LCM = product of ALL primes used = 2×2×3×3 = 36.

    Ladder method
    ♾️
    Euclidean Algorithm Worked

    GCD(18,12): 18 = 1×12 + 6; GCD(12,6): 12 = 2×6 + 0; remainder = 0, so GCD = 6 = HCF. LCM = 18×12 / 6 = 216 / 6 = 36. The algorithm is guaranteed to terminate and is extremely fast even for numbers with hundreds of digits.

    Fastest
    📋
    LCM for Adding Fractions

    To add 5/12 + 7/18, find LCM(12,18) = 36. Convert: 5/12 = 15/36, 7/18 = 14/36. Sum = 29/36. The LCM becomes the lowest common denominator (LCD). Without LCM, you'd use 12×18=216 as denominator and get larger numbers to simplify later.

    Fractions
    🔁
    LCM for Scheduling

    Bus A comes every 12 minutes, Bus B every 18 minutes. Both just left at 9:00 AM. When do they next leave together? LCM(12,18) = 36 minutes later → 9:36 AM. Any problem of the form "after how long do two periodic events coincide?" is an LCM problem.

    Real world
    🧱
    HCF for Tiling Problems

    A room is 360 cm × 252 cm. What is the largest square tile that fits exactly? HCF(360, 252). 360 = 2³×3²×5, 252 = 2²×3²×7. HCF = 2²×3² = 36 cm. So 36×36 cm tiles work perfectly with no cutting. HCF gives the largest unit that fits both dimensions exactly.

    Classic use

    How This Calculator Works

    Step-by-step: how inputs are processed, prime factorisations found, and all three methods applied

    From Numbers to Full Working
    • 1
      Enter 2 to 6 Positive Integers

      Fill the input boxes with any positive integers from 1 to 999,999. Optional boxes (marked "opt") are skipped automatically. The preset buttons and quick chips instantly load common example sets so you can explore without typing.

    • 2
      Prime Factorisation of Each Number

      The calculator trial-divides each number by 2, 3, 5, 7, 11 … up to its square root to find all prime factors and their powers. Results are displayed as colour-coded factor badges — common factors highlighted in green, unique factors in blue.

    • 3
      HCF = Min Powers, LCM = Max Powers

      Across all prime factorisations: HCF takes each prime factor at its minimum exponent across all numbers. LCM takes each prime factor at its maximum exponent. For 3+ numbers, this is extended naturally — the logic is identical.

    • 4
      All 3 Methods Computed — Selected Method Shown in Full

      Prime Factorisation, Division Method table, and Euclidean Algorithm steps are all computed. The selected method toggle controls which one gets the full step-by-step working in the steps list. The Method Comparison section always shows all three results side by side.

    • 5
      Verification — Golden Relationship Check

      For two numbers, the calculator always verifies LCM × HCF = a × b and displays whether the check passes. Visual proportion bars show each number's prime factorisation as a proportion of the LCM, making it easy to see which factors each number contributes.

    Key formulas:
    HCF(a,b) = product of common prime factors (min powers)
    LCM(a,b) = product of all prime factors (max powers)
    HCF × LCM = a × b (for two numbers only)
    LCM(a,b,c) = LCM(LCM(a,b), c)
    HCF(a,b,c) = HCF(HCF(a,b), c)
    Euclidean : GCD(a,b) = GCD(b, a mod b) until b=0

    LCM & HCF Facts, Tricks & Real-World Uses

    Fascinating properties, shortcuts, history and applications you were never taught in school

    Number Theory Is Everywhere
    📜
    Euclid's Algorithm Is 2,300 Years Old

    The Euclidean Algorithm for finding GCD appears in Euclid's Elements (c. 300 BC), making it one of the oldest algorithms still in common use. It is more efficient than prime factorisation for large numbers — finding GCD(1,000,000,007 and 998,244,353) takes only a few steps by repeated division, while factorising those numbers would take far longer.

    🔁
    LCM Powers All Fraction Arithmetic

    Whenever you add or subtract fractions with different denominators in school, you are finding an LCM — specifically the Lowest Common Denominator (LCD), which is exactly LCM(denominators). Without the LCM, fraction addition requires multiplying denominators together and then simplifying — the LCM shortcut avoids that extra simplification step.

    🔒
    RSA Encryption Uses Co-prime Numbers

    The RSA cryptographic algorithm — used in HTTPS, banking, and secure email — relies on choosing two large co-prime numbers. The security comes from the fact that while HCF(e, φ(n)) = 1 is easy to verify, recovering the factors of n from e and the public key is computationally infeasible. Every secure website you visit uses this principle.

    ⚙️
    Gear Ratios and LCM

    In mechanical engineering, two meshing gears with tooth counts a and b will repeat the same pair of teeth engaging after LCM(a,b) rotations total. Engineers choose gear tooth counts to avoid repeated wear on the same teeth — which means deliberately choosing numbers with a high LCM (i.e. low HCF, ideally co-prime). This extends gear life significantly.

    💸
    HCF Simplifies Ratios in Finance

    Sharing profits in a ratio of 48:36:24 — find HCF(48,36,24) = 12, so the simplified ratio is 4:3:2. Interest calculations, mixture problems and investment allocations all reduce to finding HCF to simplify the underlying ratio. The "simplest form" of any ratio is found by dividing all terms by their HCF.

    🎵
    Music Theory and LCM

    In music, polyrhythms occur when two rhythms with different beat counts play simultaneously. A 3-against-4 polyrhythm (triplet vs. quarter notes) repeats every LCM(3,4) = 12 subdivisions. West African drumming, jazz, and contemporary classical music all use polyrhythms whose period is an LCM. Every musician who plays in compound time is implicitly using LCM.

    💻
    Computer Science: Memory Alignment

    CPUs access memory most efficiently when data is aligned to multiples of its size. When you need a buffer that's accessible for two data structures of sizes a and b bytes, the alignment requirement is LCM(a,b). Compiler padding, struct layout, SIMD instruction alignment requirements — all solved with LCM arithmetic under the hood.

    🧮
    The LCM of 1 to n Grows Exponentially

    LCM(1,2,3,...,n) grows roughly as e^n by the prime number theorem. LCM(1..10) = 2520. LCM(1..20) = 232,792,560. LCM(1..30) ≈ 2.3 × 10¹⁴. This exponential growth is related to why the harmonic series diverges and appears in estimates for the distribution of prime numbers — a deep connection between LCM and prime counting.

    Frequently Asked Questions

    Common questions about LCM, HCF, co-prime numbers, the Euclidean Algorithm and practical uses

    What is the difference between HCF and LCM?
    HCF (Highest Common Factor) is the largest number that divides all the given numbers exactly — it is always less than or equal to the smallest number. LCM (Least Common Multiple) is the smallest number that all given numbers divide into exactly — it is always greater than or equal to the largest number. HCF deals with factors (divisors); LCM deals with multiples. For two numbers a and b: HCF × LCM = a × b. This relationship does NOT extend directly to three or more numbers.
    Does HCF × LCM = a × b work for three numbers?
    No — the product formula HCF × LCM = a × b applies only to two numbers. For three numbers a, b, c: LCM(a,b,c) = LCM(LCM(a,b), c) and HCF(a,b,c) = HCF(HCF(a,b), c). There is no simple product formula for three numbers. For example, HCF(6,10,15) = 1 and LCM(6,10,15) = 30, but 1 × 30 = 30 ≠ 6 × 10 × 15 = 900.
    What does it mean if HCF = 1?
    When HCF(a,b) = 1, the numbers are called co-prime or relatively prime — they share no common factor other than 1. This does NOT mean either number is prime. For example, 8 and 9 are co-prime (HCF = 1) even though neither is prime. Co-prime pairs have LCM = a × b. Consecutive integers are always co-prime. Co-primeness is fundamental in fractions (a fraction a/b is in lowest terms when HCF(a,b) = 1) and in cryptography.
    How does the Euclidean Algorithm work?
    The Euclidean Algorithm is based on the property that GCD(a,b) = GCD(b, a mod b). Repeatedly replace the larger number with the remainder when dividing: GCD(48,18) → GCD(18,12) → GCD(12,6) → GCD(6,0) = 6. The algorithm terminates when the remainder is 0; the last non-zero remainder is the GCD/HCF. This works because any divisor of both a and b also divides (a mod b), so the set of common divisors is preserved at each step.
    When should I use LCM vs HCF in word problems?
    Use LCM when the problem asks: "when will two events next coincide?", "what is the lowest common denominator?", "what is the smallest number divisible by both?", or "how many items are needed to make equal groups of different sizes?". Use HCF when the problem asks: "what is the largest piece/tile/group?", "simplify this ratio or fraction", "what is the maximum equal portion?", or "divide items into identical groups of maximum size?". The keyword "largest" or "maximum" usually signals HCF; "smallest" or "next time" usually signals LCM.
    Is this calculator private? Is any data stored?
    Yes, completely private. All calculations run entirely in your browser using JavaScript. No number you type is ever sent to any server, stored in any database or logged anywhere. This page works fully offline once loaded. Your inputs disappear when you close or refresh the tab.
    Where LCM & HCF Actually Appear
    Six Real-World Applications — Not Just School Maths
    🧵
    Fabric & Tile Cutting

    Cutting 360 cm and 540 cm lengths into equal pieces without wastage: HCF(360, 540) = 180 cm. Each piece is exactly 180 cm and both lengths divide evenly. HCF finds the largest unit that divides all given lengths without remainder.

    HCF(360,540) = 180
    🚌
    Bus & Train Scheduling

    Bus A departs every 12 minutes, Bus B every 18 minutes. Next time they leave together: LCM(12, 18) = 36 minutes. This synchronisation problem appears in transport planning, manufacturing cycle timing, and software task scheduling.

    LCM(12,18) = 36 min
    🧮
    Fraction Arithmetic

    To add 1/6 + 1/4, find LCM(6,4) = 12. Convert: 2/12 + 3/12 = 5/12. LCM gives the smallest common denominator, keeping numbers manageable. Without LCM, you multiply denominators (24) and get 4/24 + 6/24 = 10/24 = 5/12 — same answer, bigger numbers.

    LCM(6,4)=12 → 5/12
    📦
    Equal Distribution

    Distributing 24 pens and 36 notebooks into identical sets (no remainders, maximum sets): HCF(24,36) = 12 sets. Each set has 2 pens and 3 notebooks. HCF solves any "divide into equal groups without remainder" problem.

    HCF(24,36) = 12 sets
    💻
    Software & Cryptography

    The Euclidean Algorithm (which this calculator uses) is the foundation of RSA encryption — the most widely used public-key cryptosystem. Extended Euclidean Algorithm finds modular inverses used in digital signatures. LCM is used for synchronising timer interrupts in operating systems.

    RSA uses Euclidean Algo
    🔨
    Floor & Wall Tiling

    Finding the largest square tile that fits a 4.8 m × 3.6 m room exactly: HCF(480, 360) = 120 cm tiles. Finding when two periodic maintenance cycles (every 8 and 12 weeks) coincide next: LCM(8, 12) = 24 weeks. Both problems solved with one calculator.

    HCF(480,360)=120 cm
    Common Errors

    5 LCM and HCF Mistakes That Trip Up Students

    1
    Confusing LCM and HCF — using the wrong one for the problem. The most frequent error: using LCM when the question asks to divide into groups (needs HCF) or using HCF when the question asks when events next coincide (needs LCM). The rule: if the answer must be smaller than or equal to the inputs — think HCF (finding a common factor). If the answer must be larger than or equal to the inputs — think LCM (finding a common multiple).
    2
    Forgetting that LCM(a, b) = a × b ÷ HCF(a, b). Once you know the HCF, LCM is immediate: LCM = a × b ÷ HCF. For HCF(12, 18) = 6: LCM = 12 × 18 ÷ 6 = 36. This relationship avoids needing to find prime factorisations separately. Many students recalculate from scratch instead of using this identity, wasting time and introducing errors.
    3
    Treating co-prime numbers as having no relationship. When HCF(a, b) = 1, the numbers are co-prime (no common factors other than 1). This has a specific implication: LCM(a, b) = a × b exactly. Examples: HCF(8, 9) = 1, so LCM(8, 9) = 72 = 8 × 9. HCF(25, 36) = 1, so LCM = 900. Many students waste time trying to find common factors when there are none — recognising co-primes early saves effort.
    4
    Including 1 as a prime in prime factorisation. 1 is not a prime number. A prime must have exactly two distinct factors: 1 and itself. The number 1 has only one factor (itself), so it is neither prime nor composite. Including 1 in a prime factorisation tree invalidates the entire calculation. The smallest prime is 2, and every integer greater than 1 has a unique prime factorisation (Fundamental Theorem of Arithmetic).
    5
    Stopping the Euclidean Algorithm too early. The Euclidean Algorithm: GCD(a, b) = GCD(b, a mod b), repeat until remainder = 0. The GCD is the last non-zero remainder. A common mistake is stopping when the remainder becomes small rather than waiting for it to reach exactly 0. For GCD(48, 18): 48 = 2×18 + 12, then 18 = 1×12 + 6, then 12 = 2×6 + 0. GCD = 6 (last non-zero remainder). Stopping at 12 gives the wrong answer.
    🔢
    Built & Maintained By
    Keeroot Solutions
    Digital Product Studio · Coimbatore, India · keeroot.com · Last updated: April 2026
    This LCM & HCF Calculator is built and maintained by Keeroot Solutions. The three calculation methods — Prime Factorisation, Division Method, and Euclidean Algorithm — are implemented as taught in Indian secondary and senior secondary mathematics curricula (CBSE/ICSE). The prime factorisation algorithm uses trial division up to the square root. The Euclidean Algorithm follows the standard recursive GCD definition. Step-by-step working is generated for each method. All calculations run locally in your browser.
    ✅ 3 solution methods📐 CBSE/ICSE aligned🔒 No data stored📅 Updated April 2026