1 | #-----------------------------------------------------------------------------
|
2 | #
|
3 | # Bignum GCD
|
4 | #
|
5 | # Uses the binary GCD algorithm.
|
6 | #
|
7 | # See "The Art of Computer Programming" p. 338.
|
8 | #
|
9 | # mgcd always returns a positive value
|
10 | #
|
11 | # mgcd(0, 0) = 0
|
12 | #
|
13 | # mgcd(u, 0) = |u|
|
14 | #
|
15 | # mgcd(0, v) = |v|
|
16 | #
|
17 | #-----------------------------------------------------------------------------
|
18 |
|
19 |
|
20 |
|
21 | mgcd = (u,v) ->
|
22 | return bigInt.gcd(u,v)
|
23 |
|
24 | #if SELFTEST
|
25 |
|