def BigInt.gcd
import bend-kit-bignum@0.1.0.0/bigint.bend as Bigintimport Base
460# Never negative; gcd(0, 0) is 0.
461def BigInt.gcd(a: BigInt, b: BigInt) -> BigInt:
462 match a b:
463 case BigInt{sa, +x} BigInt{sb, +y}:
464 BigInt{False{}, Mag.gcd(
465 Nat.add(Nat.mul(Nat.add(Mag.len(x), Mag.len(y)), 20n), 2n), x, y)}