LCM

Math & Trigonometry Functions
(4.7/5)

Returns the least common multiple (LCM) of two or more integers. LCM is the smallest positive integer that is a multiple of each of the numbers. Essential for fraction operations, finding common denominators, scheduling problems, and mathematical calculations.

Interactive Formula Tester

=LCM("12, 18")

Complete Theory & Understanding

Master the fundamentals of Excel LCM function

Core Concept

The LCM function returns the least common multiple of two or more integers. LCM is the smallest positive integer that is a multiple of each of the numbers. Key properties: LCM(a, b) = LCM(b, a) (commutative), LCM(a, a) = a, LCM(a, b) × GCD(a, b) = a × b (fundamental relationship), LCM of coprime numbers equals their product. Essential for finding common denominators in fraction operations, scheduling problems (finding when events align), number theory, and mathematical calculations.

Why Use LCM?

  • Find common denominators
  • Find when events align
  • Mathematical number theory
  • General mathematical calculations

Key Characteristics

Commutative

LCM(a, b) = LCM(b, a)

LCM(12, 18) = LCM(18, 12) = 36

Multiple Numbers

Works with 2 or more numbers

LCM(4, 6, 8) = 24

GCD Relationship

LCM × GCD = product

LCM(12,18) × GCD(12,18) = 12 × 18

Common Denominator

Use to find common denominators

LCM(4, 6) = 12 for fractions

Function Anatomy

=LCM(parameters...)
Required
Parameters:

Function-specific parameters

Returns
Return Value:

Function-specific return type

Primary Use Cases

Fraction Operations

Find common denominators

Scheduling

Find when events align

Number Theory

Mathematical number theory

Mathematical Calculations

General mathematical calculations

Theory Summary

Precise

Exact matching required

Position-Based

Returns numeric position

Error-Safe

Handles missing text gracefully

Syntax & Parameters

=LCM(number1, number2)
Required
number1:

First number. Must be an integer.

Optional
number2:

Additional numbers (up to 255). Must be integers.

Returns
Return Value:

The least common multiple

Description: Returns the least common multiple of two or more integers

Interactive Examples

Basic LCM

LCM of two numbers

"12, 18"
=LCM(12, 18)
36

Returns 36 because LCM(12, 18) = 36. The smallest number that is a multiple of both 12 and 18 is 36 (36 = 12×3, 36 = 18×2).

VBA Implementation & Automation

Basic LCM in VBA

Use LCM function in VBA

' Basic LCM in VBA
Range("C1").Value = Application.WorksheetFunction.Lcm(12, 18)
' Returns: 36

' Calculate LCM
Sub CalculateLCM()
    Dim num1 As Integer
    Dim num2 As Integer
    num1 = Range("A1").Value
    num2 = Range("A2").Value
    Dim result As Integer
    result = Application.WorksheetFunction.Lcm(num1, num2)
    Range("B1").Value = result
End Sub

' Calculate LCM of three numbers
Sub CalculateLCMThree()
    Dim num1 As Integer
    Dim num2 As Integer
    Dim num3 As Integer
    num1 = Range("A1").Value
    num2 = Range("A2").Value
    num3 = Range("A3").Value
    Dim result As Integer
    result = Application.WorksheetFunction.Lcm(num1, num2, num3)
    Range("B1").Value = result
End Sub

' Find common denominator for fractions
Sub FindCommonDenominator()
    Dim den1 As Integer
    Dim den2 As Integer
    den1 = Range("A1").Value
    den2 = Range("A2").Value
    Dim lcm As Integer
    lcm = Application.WorksheetFunction.Lcm(den1, den2)
    Range("B1").Value = "Common denominator: " & lcm
End Sub

' Verify LCM × GCD relationship
Sub VerifyLCMGCDRelationship()
    Dim num1 As Integer
    Dim num2 As Integer
    num1 = Range("A1").Value
    num2 = Range("A2").Value
    Dim lcm As Integer
    Dim gcd As Integer
    Dim product As Integer
    lcm = Application.WorksheetFunction.Lcm(num1, num2)
    gcd = Application.WorksheetFunction.Gcd(num1, num2)
    product = num1 * num2
    Range("B1").Value = "LCM: " & lcm
    Range("B2").Value = "GCD: " & gcd
    Range("B3").Value = "LCM × GCD: " & (lcm * gcd)
    Range("B4").Value = "Product: " & product
    ' Should be equal
End Sub

Business Applications

Fraction Operations

Find common denominators for adding/subtracting

=LCM(denominator1, denominator2)

Scheduling

Find when events align

=LCM(cycle1, cycle2)

Number Theory

Mathematical number theory calculations

=LCM(number1, number2)

Mathematical Calculations

General mathematical calculations

=LCM(a, b, c)

Common Issues & Solutions

#NUM! Error

LCM returns #NUM! for non-integers or zero

=LCM(ABS(INT(A1)), ABS(INT(A2)))

Solution: LCM only works with positive integers. Negative numbers are converted to absolute values. Decimals are truncated. At least one number must be non-zero. Ensure inputs are positive integers.

#VALUE! Error

Non-numeric input in LCM

=LCM(VALUE(A1), VALUE(A2))

Solution: Ensure all inputs are numeric. LCM requires numbers. Check for text, errors, or empty cells. Use VALUE() if needed.

All Zeros

LCM(0, 0) returns error

Ensure at least one non-zero number

Solution: LCM(0, 0) = #NUM!. At least one number must be non-zero. LCM(n, 0) = 0 for n > 0.

Finding Common Denominator

How to use LCM to add fractions

=A1 & "/" & LCM(B1,B2) & " + " & A2 & "/" & LCM(B1,B2)

Solution: To add a/b + c/d: Find LCM(b, d) = lcm. Convert: a/b = (a × lcm/b)/lcm, c/d = (c × lcm/d)/lcm. Add numerators. Example: 1/4 + 1/6, LCM(4,6)=12, so 3/12 + 2/12 = 5/12.

Performance Tips & Best Practices

⚡ Performance Optimization

  • LCM is fast - minimal performance impact
  • LCM uses efficient algorithm
  • Works efficiently in array formulas
  • Can handle up to 255 numbers
  • Negative numbers are converted to absolute values automatically

🎯 Best Practices

  • Remember LCM(n, n) = n
  • LCM of coprime numbers equals their product
  • Use LCM to find common denominators
  • LCM works with 2 or more numbers
  • LCM(a, b) × GCD(a, b) = a × b
  • Test with known values: LCM(12, 18) = 36
  • LCM is commutative: LCM(a, b) = LCM(b, a)
  • Use for fraction operations and scheduling
  • Document when using LCM in formulas