Toolbox-XToolbox-X

Calculate LCM (LCD)

Calculates the least common multiple of multiple numbers.

calculateLCM

The calculateLCM function calculates the least common multiple (LCM), also known as the least common divisor (LCD), of multiple provided numbers.

Function Signature

function calculateLCM(...numbers: Numeric[]): number

Parameters

  • numbers (Numeric[]): A list of numbers or numeric strings for which the LCM/LCD is to be calculated.

Return Value

  • number: The LCM/LCD of the provided numbers. If no valid numbers are provided, it returns 0.

Example Usage

playground.ts

Notes

  • The function works by progressively finding the LCM of pairs of numbers.
  • If no valid numbers are provided, it returns 0 as the LCM/LCD.
  • The LCM of a single number is the number itself.
  • Only integer values are considered valid for calculating LCM/LCD.

Aliases

  • calculateLCD

See Also

Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)

On this page