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

Function gcd

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

Source from the content-addressed store, hash-verified

164 }
165 const factors = primeFactors(n);
166 let f = BigInt(1);
167 let r = BigInt(1);
168 for (const k of Object.keys(factors)) {
169 const v = BigInt(parseInt(k));
170 const exponentBase = BigInt(exponent);
171 f = f * v ** (BigInt(factors[Number(k)]) / exponentBase);
172 r = r * v ** (BigInt(factors[Number(k)]) % exponentBase);
173 }
174 return [Number(f), Number(r)];
175}
176
177export function gcd(a: number, b: number): number {

Callers 8

simplify-rules.tsFile · 0.90
integerLogRationalFunction · 0.90
toRationalMethod · 0.90
gcdMethod · 0.90
lcmFunction · 0.70
cantorEnumerateRationalsFunction · 0.70

Calls 1

isIntegerMethod · 0.45

Tested by

no test coverage detected