Skip to content

bigIntGcd

bigIntGcd(a, b): bigint

Defined in: big-int/gcd.ts:10

Greatest common divisor, by the binary (Stein) algorithm.

Always non-negative; bigIntGcd(0n, 0n) is 0n. Stein’s algorithm avoids division entirely, using only subtraction and shifts, which bigint implements more cheaply than % at large widths.

bigint

bigint

bigint