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

Function gcd

src/compute-engine/numerics/bernoulli.ts:16–21  ·  view source on GitHub ↗

* Exact Bernoulli numbers and exact values of the Riemann zeta function at * integers, computed with bigint rationals. * * Used by the exact (non-numericApproximation) evaluation path of `Zeta` * in `library/arithmetic.ts`: * * - ζ(2k) = (−1)^{k+1} · B₂ₖ · (2π)^{2k} / (2·(2k)!) → rational ·

(a: bigint, b: bigint)

Source from the content-addressed store, hash-verified

14 */
15
16function gcd(a: bigint, b: bigint): bigint {
17 if (a < 0n) a = -a;
18 if (b < 0n) b = -b;
19 while (b !== 0n) [a, b] = [b, a % b];
20 return a;
21}
22
23function reduce(num: bigint, den: bigint): [bigint, bigint] {
24 if (den < 0n) {

Callers 1

reduceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected