Natural.inv_step: def of bend-collections@1.0.0.0 Import: import bend-collections@1.0.0.0/src/math/natural.bend as Natural Lines 300-303 of bend-collections@1.0.0.0/src/math/natural.bend: https://jend.leeeet.dev/read.txt?path=bend-collections@1.0.0.0/src/math/natural.bend&start_line=300&end_line=303 import Base # Extended Euclid on (m, a mod m) keeping only the coefficient of a, mod m: # a * s0 == r0 and a * s1 == r1 (mod m). The remainders are gcd's. def inv_step(+m: Nat, +q: Nat, +s0: Nat, +s1: Nat) -> Nat: Nat.mod(Nat.add(s0, Nat.sub(m, Nat.mod(Nat.mul(q, s1), m))), m) Uses (5): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub