LCM Calculator Formula

Understand the math behind the lcm calculator. Each variable explained with a worked example.

Formulas Used

Lcm Val

lcm_val = abs(a * b) / gcd(a, b)

Gcd Val

gcd_val = gcd(a, b)

Product

product = a * b

Variables

VariableDescriptionDefault
aNumber A12
bNumber B18

How It Works

Least Common Multiple (LCM)

Definition

The LCM of two numbers is the smallest positive integer that is divisible by both numbers.

Formula

LCM(a, b) = a × b / GCD(a, b)

Example

LCM(12, 18):

  • GCD(12, 18) = 6
  • LCM = (12 × 18) / 6 = 216 / 6 = 36
  • Worked Example

    Find LCM(12, 18).

    a = 12b = 18
    1. 01GCD(12, 18) = 6
    2. 02LCM = (12 × 18) / 6
    3. 03= 216 / 6
    4. 04= 36

    Frequently Asked Questions

    What is LCM?

    The least common multiple is the smallest number that both numbers divide into evenly. For example, LCM(4, 6) = 12.

    When is LCM useful?

    LCM is used when adding fractions (finding a common denominator), scheduling events that repeat at different intervals, and in number theory.

    What is the relationship between GCD and LCM?

    GCD(a,b) × LCM(a,b) = a × b. Knowing one lets you calculate the other.

    Learn More

    Guide

    Understanding Prime Numbers - Complete Guide

    Learn what prime numbers are, how to identify them, prime factorization, the Sieve of Eratosthenes, and why primes matter in cryptography and mathematics.

    Ready to run the numbers?

    Open LCM Calculator