Skip to main content

Function: lcm()

lcm(original, timeoutMs): number

Defined in: utils/utils.ts:472

this is an algorithm for finding the least common multiple of a give set of input numbers it works based on the formula lcd (a,b) = a*b / gcd(a,b), and then calculates in a pairwise fashion. this has the risk of breaking with very large sets of inputs and/or prime numbers of a large size

Parameters

original

number[]

array of numbers to find the LCM of

timeoutMs

number

optional timeout in milliseconds. If provided and exceeded, returns -1 (gcd will always be positive so we can use -1 aS A FLAG)

Returns

number