From d8c9f22d97e46b76398d47ffc70184159a9a4d77 Mon Sep 17 00:00:00 2001 From: atsiv sivat Date: Sat, 31 Jan 2026 15:49:47 +0000 Subject: [PATCH] add function which finds the greatest common divisor of two BigInts --- src/core/Utils.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/Utils.mjs b/src/core/Utils.mjs index a9c381d7..9149d9a8 100755 --- a/src/core/Utils.mjs +++ b/src/core/Utils.mjs @@ -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.