Greatest Common Divisor

Find the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.

Code

Algorithms
const gcd = (x, y) => y === 0 ? x : gcd(y, x % y);
return gcd(a, b);

Parameters

First number

Second number

Browser·fetch() may be limited by CORS

More JavaScript Snippets