This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -1,3 +1,2 @@
gcd = (x, y) ->
return x if y == 0
gcd(y, x % y)
if y == 0 then x else gcd y, x % y

View file

@ -1,9 +1,3 @@
ggt = (x,y) ->
max_teiler = Math.min(x,y)
ggt = 0
for teiler in [1..max_teiler]
if x % teiler == 0 and y % teiler == 0
ggt = teiler
return ggt
alert ggt(40902,24140)
gcd = (x, y) ->
[1..(Math.min x, y)].reduce (acc, v) ->
if x % v == 0 and y % v == 0 then v else acc