add function which finds the greatest common divisor of two BigInts

This commit is contained in:
atsiv sivat 2026-01-31 15:49:47 +00:00
parent 2a1294f1c0
commit d8c9f22d97

View File

@ -1263,6 +1263,18 @@ class Utils {
return Utils.gcd(y, x % y);
}
/**
* Finds the greatest common divisor of two BigInt numbers.
*
* @author atsiv1 [atsiv1@proton.me]
* @param {BigInt} x
* @param {BigInt} y
* @returns {BigInt}
*/
static gcdBigInt(a, b) {
return b === 0n ? a : Utils.gcdBigInt(b, a % b);
}
/**
* Finds the modular inverse of two values.