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 / research / om-bench / controls / fibo-empty.om

53 lines · 749 bytes Raw Blame History
1note Read unsigned decimal numbers separated by spaces or newlines from stdin; print their sum.
2global inb uchar 65536
3global outb uchar 32
4fn readall to ulong
5n = ulong 0
6while lt n 65536 bound 65537
7k = read 0 inb n sub 65536 n
8if lt k 0
9exit 2
10end
11if eq k 0
12break
13end
14n = add n ulong k
15end
16ret n
17end
18fn printu v ulong to void
19i = ulong 31
20put outb i 10
21x = v
22while true bound 21
23i = sub i 1
24put outb i uchar add rem x 10 48
25x = div x 10
26if eq x 0
27break
28end
29end
30off = i
31k = write 1 outb off sub 32 off
32if ne k long sub 32 off
33exit 3
34end
35end
36fn main to int
37n = readall
38v = ulong 0
39for i ulong n
40c = get inb i
41if and ge c 48 le c 57
42v = add mul v 10 ulong sub c 48
43end
44end
45a = ulong 0
46b = ulong 1
47for i ulong v
48t = add a b
49a = b
50b = t
51end
52ret 0
53end