lcm
Returns the least common multiple of two expressions.
Numeric inputs use exact rational arithmetic. For symbolic polynomial expressions, Nerdamer computes the product divided by the symbolic greatest common divisor so shared factors are retained.
If either operand is zero, the result is zero.
Examples
These examples use Nerdamer Notation.
Compute an exact integer least common multiple.
lcm(6,4)
// → 12Retain the shared polynomial factor once while combining the distinct factors.
lcm((x-1)*(x+2),(x-1)*(x+3))
// → (2+x)*(3+x)*(-1+x)Apply the zero case.
lcm(0,x)
// → 0Interfaces
The same operation is available through the interfaces below.
Nerdamer Notation
Use this form inside input passed to nerdamer(...).
lcm(arg1, arg2)
nerdamer.lcm
Call the operation through the default nerdamer import.
nerdamer.lcm(x: ExpressionInput, y: ExpressionInput): Expression
Parameters
| Name | Type | Description |
|---|---|---|
x | ExpressionInput | First expression-compatible operand. |
y | ExpressionInput | Second expression-compatible operand. |
Returns
Expression — Zero when either operand is zero; otherwise a non-negative numeric LCM or
the symbolic product divided by gcd.
Direct JavaScript / TypeScript API
Import the operation directly from its package entry point.
import { lcm } from 'nerdamer/algebra';
lcm(x: ExpressionInput, y: ExpressionInput): Expression
Parameters
| Name | Type | Description |
|---|---|---|
x | ExpressionInput | First expression-compatible operand. |
y | ExpressionInput | Second expression-compatible operand. |
Returns
Expression — Zero when either operand is zero; otherwise a non-negative numeric LCM or
the symbolic product divided by gcd.
