interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tools / exp445 / arms / examples / power_mod / prompt

4 lines · 391 bytes Raw Blame History
1Write a function power_mod that takes three unsigned 32-bit numbers b, e and m and returns b to the
2power e, modulo m (0 to the power 0 is 1). Work in unsigned 64-bit numbers: start with r = 1 mod m
3and x = b mod m, then while e > 0: if e is odd, r = r * x mod m; x = x * x mod m; e = e / 2. Use a
4helper function for "a * b mod m". When m is 0 the run stops with trap 2 (division by zero).