effect-io-ai

Package: effect
Module: BigInt

BigInt.gcd

Determines the greatest common divisor of two bigints.

When to use

Use to compute the greatest common divisor of two integer values.

Example (Calculating greatest common divisors)

import { BigInt } from "effect"
import * as assert from "node:assert"

assert.deepStrictEqual(BigInt.gcd(2n, 3n), 1n)
assert.deepStrictEqual(BigInt.gcd(2n, 4n), 2n)
assert.deepStrictEqual(BigInt.gcd(16n, 24n), 8n)

See

Signature

declare const gcd: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint; }

Source

Since v2.0.0