Skip to content

Latest commit

 

History

History
9 lines (7 loc) · 240 Bytes

greatest-common-divisor-(GCD).md

File metadata and controls

9 lines (7 loc) · 240 Bytes

Greatest common divisor (GCD)

Use recursion. Base case is when y equals 0. In this case, return x. Otherwise, return the GCD of y and the remainder of the division x/y.

var gcd = (x , y) => !y ? x : gcd(y, x % y);