A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1,11 @@
|
|||
function gcd(a,b) {
|
||||
if (a < 0) a = -a;
|
||||
if (b < 0) b = -b;
|
||||
if (b > a) {var temp = a; a = b; b = temp;}
|
||||
while (true) {
|
||||
a %= b;
|
||||
if (a == 0) return b;
|
||||
b %= a;
|
||||
if (b == 0) return a;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
function gcd_rec(a, b) {
|
||||
if (b) {
|
||||
return gcd_rec(b, a % b);
|
||||
} else {
|
||||
return Math.abs(a);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue