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.
Master the fundamentals of Excel LCM function
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.
LCM(a, b) = LCM(b, a)
Works with 2 or more numbers
LCM × GCD = product
Use to find common denominators
Function-specific parameters
Function-specific return type
Find common denominators
Find when events align
Mathematical number theory
General mathematical calculations
Exact matching required
Returns numeric position
Handles missing text gracefully
=LCM(number1, number2)First number. Must be an integer.
Additional numbers (up to 255). Must be integers.
The least common multiple
Description: Returns the least common multiple of two or more integers
LCM of two numbers
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).
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 SubFind common denominators for adding/subtracting
Find when events align
Mathematical number theory calculations
General mathematical calculations
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.
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.
LCM(0, 0) returns error
Ensure at least one non-zero numberSolution: LCM(0, 0) = #NUM!. At least one number must be non-zero. LCM(n, 0) = 0 for n > 0.
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.