Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 401 Bytes

compute-the-greatest-common-divisor-between-two-numbers.mdx

File metadata and controls

24 lines (18 loc) · 401 Bytes
category created title updated
Number
2020-04-23
Compute the greatest common divisor between two numbers
2021-10-13

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