Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,11 +1,17 @@
|
|||
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;
|
||||
}
|
||||
a = Math.abs(a);
|
||||
b = Math.abs(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; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue