Hyperlinkv0.8.0-beta.28

BigInt

BigInt.lcmconsteffect/BigInt.ts:660
(that: bigint): (self: bigint) => bigint
(self: bigint, that: bigint): bigint

Determines the least common multiple of two bigints.

When to use

Use to compute the least common multiple of two integer values.

Example (Calculating least common multiples)

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

assert.deepStrictEqual(BigInt.lcm(2n, 3n), 6n)
assert.deepStrictEqual(BigInt.lcm(2n, 4n), 4n)
assert.deepStrictEqual(BigInt.lcm(16n, 24n), 48n)
mathgcd
Source effect/BigInt.ts:6604 lines
export const lcm: {
  (that: bigint): (self: bigint) => bigint
  (self: bigint, that: bigint): bigint
} = dual(2, (self: bigint, that: bigint): bigint => (self * that) / gcd(self, that))