RosettaCodeData/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-2.coffee
2023-07-01 13:44:08 -04:00

3 lines
107 B
CoffeeScript

gcd = (x, y) ->
[1..(Math.min x, y)].reduce (acc, v) ->
if x % v == 0 and y % v == 0 then v else acc