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 / program.osc

16 lines · 377 bytes Raw Blame History
1fn mod(a: u64, b: u64, m: u64) -> u64 {
2 return a * b % m;
3}
4
5fn power_mod(b: u32, e: u32, m: u32) -> u32 {
6 let mm: u64 = m as u64;
7 let mut r: u64 = 1 % mm;
8 let mut x: u64 = (b as u64) % mm;
9 let mut k: u32 = e;
10 while k > 0 bound 40 {
11 if k % 2 == 1 { r = mod(r, x, mm); }
12 x = mod(x, x, mm);
13 k = k / 2;
14 }
15 return r as u32;
16}