def inv_step

bend-collections-laws-math@1.0.0.0 · src/math/natural.bend:300

import bend-collections-laws-math@1.0.0.0/src/math/natural.bend as Natural
import Base

300# Extended Euclid on (m, a mod m) keeping only the coefficient of a, mod m:
301# a * s0 == r0 and a * s1 == r1 (mod m). The remainders are gcd's.
302def inv_step(+m: Nat, +q: Nat, +s0: Nat, +s1: Nat) -> Nat:
303  Nat.mod(Nat.add(s0, Nat.sub(m, Nat.mod(Nat.mul(q, s1), m))), m)

Uses (5)

Used by (9)