MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / lcm

Function lcm

src/compute-engine/numerics/numeric-bignum.ts:11–14  ·  view source on GitHub ↗
(a: BigNum, b: BigNum)

Source from the content-addressed store, hash-verified

9}
10
11export function lcm(a: BigNum, b: BigNum): BigNum {
12 // `lcm(0, n) = 0`: the general formula would divide by `gcd(0, 0) = 0`.
13 if (a.isZero() || b.isZero()) return BigDecimal.ZERO;
14 // The least common multiple is non-negative by convention.
15 return a.mul(b).div(gcd(a, b)).abs();
16}
17

Callers

nothing calls this directly

Calls 4

gcdFunction · 0.70
absMethod · 0.65
divMethod · 0.65
mulMethod · 0.65

Tested by

no test coverage detected