Number.EGcd: type of bend-collections-laws-math@1.0.0.0 Import: import bend-collections-laws-math@1.0.0.0/src/math/number.bend as Number Lines 15-21 of bend-collections-laws-math@1.0.0.0/src/math/number.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-math@1.0.0.0/src/math/number.bend&start_line=15&end_line=21 import Base # gcd(a, b) and signed Bezout coefficients split into magnitudes and a sign: # neg == False: a * x == gcd + b * y (a*x - b*y == gcd) # neg == True: b * y == gcd + a * x (b*y - a*x == gcd) # Python's egcd would return one negative coefficient; the unsigned library # returns both magnitudes and says which side carries the minus sign. type EGcd is Data: EG{gcd: Nat, x: Nat, y: Nat, neg: Bool} Uses (2): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat