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/si/rosetta/tasks/anti-primes/anti-primes.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 / si / rosetta / tasks / anti-primes / anti-primes.om` 66 lines ยท 1191 bytes Raw Blame History 1 note Rosetta Code task "Anti-primes": https://rosettacode.org/wiki/Anti-primes 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text sp " " 6 text first "first 20 anti-primes:" 7 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 8 fn emit a view uchar * to void 9 o = ulong 0 10 while lt o len a bound 4096 11 k = write 1 a o sub len a o 12 if le k 0 13 exit 1 14 end 15 o = add o ulong k 16 end 17 end 18 note emitu writes n in decimal; 20 digits hold every ulong 19 fn emitu n ulong to void 20 d = new uchar 20 0 21 i = ulong 20 22 v = n 23 while true bound 20 24 i = sub i 1 25 put d i uchar add rem v 10 48 26 v = div v 10 27 if eq v 0 28 break 29 end 30 end 31 emit part d i sub 20 i 32 end 33 note divisor count by pairing d with n / d for d * d <= n 34 fn ndiv n ulong to ulong 35 c = ulong 0 36 d = ulong 1 37 while le mul d d n bound 100 38 if eq rem n d 0 39 c = add c 2 40 if eq mul d d n 41 c = sub c 1 42 end 43 end 44 d = add d 1 45 end 46 ret c 47 end 48 note an anti-prime has more divisors than every smaller positive integer; the 20th is 7560 49 fn main to int 50 emit first 51 best = ulong 0 52 c = ulong 0 53 n = ulong 1 54 while lt c 20 bound 7560 55 k = ndiv n 56 if gt k best 57 best = k 58 emit sp 59 emitu n 60 c = add c 1 61 end 62 n = add n 1 63 end 64 emit nl 65 ret 0 66 end