def eg_neg
import bend-collections-laws-math@1.0.0.0/spec/math/number.bend as Numberimport Base
import bend-collections-laws-math@1.0.0.0/src/math/number.bend as NB
53def eg_neg(+a: Nat, +b: Nat, r: NB.EGcd) -> Nat:
54 match r:
55 case NB.EG{+g, +x, +y, neg}:
56 match neg:
57 case True{}:
58 Nat.add(g, Nat.mul(a, x))
59 case False{}:
60 Nat.add(g, Nat.mul(b, y))