* @function gcd * @description Euclid's GCD algorithm. * @param {BigInt} A * @param {BigInt} B * @returns Greatest Common Divisor between A and B.
(A, B)
| 88 | * @returns Greatest Common Divisor between A and B. |
| 89 | */ |
| 90 | function gcd(A, B) { |
| 91 | while (B !== 0n) { |
| 92 | ;[A, B] = [B, A % B] |
| 93 | } |
| 94 | |
| 95 | return Number(A) |
| 96 | } |
| 97 | |
| 98 | export { ShorsAlgorithm } |