def pow_mod_go

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

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

284def pow_mod_go(fuel: Nat, +m: Nat, +e: Nat, +base: Nat, +acc: Nat) -> Nat:
285  match fuel e:
286    case 0n _:
287      acc
288    case 1n+f 0n:
289      acc
290    case 1n+f 1n+ +ep:
291      pow_mod_go(f, m, Nat.div(1n+ep, 2n), Nat.mod(Nat.mul(base, base), m), pow_mod_odd(m, Nat.mod(1n+ep, 2n), base, acc))

Uses (5)

Used by (1)