GitHub 6219★

Compute the greatest common divisor between two numbers

JavaScript version

const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b));

TypeScript version

const gcd = (a: number, b: number): number => (b === 0 ? a : gcd(b, a % b));

Examples

gcd(10, 15); // 5
Follow me on and to get more useful contents.