MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / gcd

Function gcd

Maths/ShorsAlgorithm.js:90–96  ·  view source on GitHub ↗

* @function gcd * @description Euclid's GCD algorithm. * @param {BigInt} A * @param {BigInt} B * @returns Greatest Common Divisor between A and B.

(A, B)

Source from the content-addressed store, hash-verified

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

Callers 1

ShorsAlgorithmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected