Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/compiler/progs/factorial.osc # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / compiler / progs / factorial.osc` 24 lines ยท 599 bytes Raw Blame History 1 // entry: fact_i32 fact_u16 2 // expect-run: fact_i32 12 -> `479001600` 3 // expect-run: fact_i32 13 -> trap=OVERFLOW 4 // expect-run: fact_i32 `4294967295` -> `4294967295` 5 // expect-run: fact_u16 5 -> 120 6 // checked factorial in i32 (OVERFLOW from 13!), wrapping in u16. 7 fn fact_i32(n: i32) -> i32 { 8 if n < 0 { return -1; } 9 let mut r: i32 = 1; 10 let mut k: i32 = 2; 11 while k <= n bound 40 { 12 r = r * k; 13 k = k + 1; 14 } 15 return r; 16 } 17 18 fn fact_u16(n: u8) -> u16 { 19 let mut r: u16 = 1; 20 for k in 2 .. 30 { 21 if k as u8 <= n { r = r * (k as u16); } 22 } 23 return r; 24 }