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

Function lcm

src/compute-engine/numerics/numeric.ts:199–206  ·  view source on GitHub ↗
(a: number, b: number)

Source from the content-addressed store, hash-verified

197 //https://github.com/Yaffle/bigint-gcd/blob/main/gcd.js
198 if (!Number.isInteger(a) || !Number.isInteger(b)) return NaN;
199 while (b !== 0) [a, b] = [b, a % b];
200 return a < 0 ? -a : a;
201}
202/*
203 Consider implementing a Binary GCD algorithm.
204 Performance is not necessarily better, so benchmark before adopting.
205
206var gcd = function (a, b) {
207 if (a === 0) return b;
208 if (b === 0) return a;
209 if (a === b) return a;

Callers

nothing calls this directly

Calls 1

gcdFunction · 0.70

Tested by

no test coverage detected