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

    Ready to run the numbers?

    Open LCM Calculator