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/seed/ng/front/kernels/sieve.om # 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 / seed / ng / front / kernels / sieve.om` 56 lines ยท 1067 bytes Raw Blame History 1 note sieve: 50 fresh passes of the sieve of Eratosthenes over 0 .. `2000000` in a global byte array; 2 note prints the prime count of the last pass and the sum of the counts of all passes. 3 note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without 4 note start-up and output) as one decimal line on stderr; stdout is unchanged. 5 global out uchar 32 6 global fl uchar `2000001` 7 fn putnum fd int v ulong to void 8 put out 31 10 9 p = ulong 31 10 x = v 11 while gt x 9 12 p = sub p 1 13 put out p uchar add rem x 10 48 14 x = div x 10 15 end 16 p = sub p 1 17 put out p uchar add x 48 18 w = write fd out p sub 32 p 19 end 20 fn pass to ulong 21 for i ulong `2000001` 22 put fl i 0 23 end 24 p = ulong 2 25 while le mul p p `2000000` 26 if eq get fl p 0 27 m = mul p p 28 while le m `2000000` 29 put fl m 1 30 m = add m p 31 end 32 end 33 p = add p 1 34 end 35 c = ulong 0 36 for i ulong `1999999` 37 if eq get fl add i 2 0 38 c = add c 1 39 end 40 end 41 ret c 42 end 43 fn main to int 44 t0 = monons 45 sum = ulong 0 46 last = ulong 0 47 for r ulong 50 48 last = pass 49 sum = add sum last 50 end 51 t1 = monons 52 putnum 2 ulong sub t1 t0 53 putnum 1 last 54 putnum 1 sum 55 ret 0 56 end