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

Function gcd

src/compute-engine/numerics/numeric-bigint.ts:4–7  ·  view source on GitHub ↗
(a: bigint, b: bigint)

Source from the content-addressed store, hash-verified

2import { bigPrimeFactors } from './primes.js';
3
4export function gcd(a: bigint, b: bigint): bigint {
5 while (b !== BigInt(0)) [a, b] = [b, a % b];
6 return a < 0 ? -a : a;
7}
8
9export function lcm(a: bigint, b: bigint): bigint {
10 // `lcm(0, n) = 0`: the general formula would divide by `gcd(0, 0) = 0`.

Callers 6

number-theory.tsFile · 0.90
reduceRatFunction · 0.90
bernoulliNumberFunction · 0.90
rationalGcdFunction · 0.90
reducedRationalFunction · 0.90
lcmFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected