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-rosetta/blob/main/drafts/rosettacode/van-eck-sequence.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / van-eck-sequence.wiki` 68 lines ยท 1426 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text first "terms 1 to 10:" 9 text last "terms 991 to 1000:" 10 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 11 fn emit a view uchar * to void 12 o = ulong 0 13 while lt o len a bound 4096 14 k = write 1 a o sub len a o 15 if le k 0 16 exit 1 17 end 18 o = add o ulong k 19 end 20 end 21 note emitu writes n in decimal; 20 digits hold every ulong 22 fn emitu n ulong to void 23 d = new uchar 20 0 24 i = ulong 20 25 v = n 26 while true bound 20 27 i = sub i 1 28 put d i uchar add rem v 10 48 29 v = div v 10 30 if eq v 0 31 break 32 end 33 end 34 emit part d i sub 20 i 35 end 36 note a(0) = 0; a(n+1) = n - m where m < n is the last earlier index with a(m) = a(n), else 0 37 note ls v is one more than the last index holding v (0: not seen); every term is below 1000, its index 38 fn main to int 39 a = new ulong 1000 0 40 ls = new ulong 1000 0 41 for n ulong 999 42 v = get a n 43 w = get ls v 44 if gt w 0 45 put a add n 1 sub n sub w 1 46 end 47 put ls v add n 1 48 end 49 emit first 50 for i ulong 10 51 emit sp 52 emitu get a i 53 end 54 emit nl 55 emit last 56 for i ulong 10 57 emit sp 58 emitu get a add 990 i 59 end 60 emit nl 61 ret 0 62 end 63 64 {{out}} 65

66 terms 1 to 10: 0 0 1 0 2 0 2 2 1 6

67 terms 991 to 1000: 4 7 30 25 67 225 488 0 10 136

68