Function reference · Algebra

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)
// → 12

Recognize that identical symbolic factors need only appear once.

lcm(x,x)
// → x

Apply the zero case.

lcm(0,x)
// → 0

Interfaces

The same operation is available through the interfaces below.

Nerdamer Notation · nerdamer API · Direct API

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

NameTypeDescription
xExpressionInputFirst expression-compatible operand.
yExpressionInputSecond expression-compatible operand.

Returns

Expression — Zero when either operand is zero; otherwise a non-negative numeric LCM or the symbolic product divided by gcd.

Browse the nerdamer API →

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

NameTypeDescription
xExpressionInputFirst expression-compatible operand.
yExpressionInputSecond expression-compatible operand.

Returns

Expression — Zero when either operand is zero; otherwise a non-negative numeric LCM or the symbolic product divided by gcd.

Browse nerdamer/algebra

← Back to Reference