RosettaCodeData/Task/Greatest-common-divisor/CoffeeScript/greatest-common-divisor-2.coffee
Ingy döt Net 776bba907c Sync
2013-10-27 22:24:23 +00: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