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/hofstadter-figure-figure-sequences.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 / hofstadter-figure-figure-sequences.wiki` 110 lines ยท 2118 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 "R(1) to R(10):" 9 text chk "first 40 R and first 960 S cover 1..1000 exactly once: " 10 text yes "yes\n" 11 text no "no\n" 12 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 13 fn emit a view uchar * to void 14 o = ulong 0 15 while lt o len a bound 4096 16 k = write 1 a o sub len a o 17 if le k 0 18 exit 1 19 end 20 o = add o ulong k 21 end 22 end 23 note emitu writes n in decimal; 20 digits hold every ulong 24 fn emitu n ulong to void 25 d = new uchar 20 0 26 i = ulong 20 27 v = n 28 while true bound 20 29 i = sub i 1 30 put d i uchar add rem v 10 48 31 v = div v 10 32 if eq v 0 33 break 34 end 35 end 36 emit part d i sub 20 i 37 end 38 note R(1) = 1, S(1) = 2, R(n) = R(n-1) + S(n-1), S(n) = the least integer above S(n-1) not in R 39 note r holds R(1..50) (R(50) = 1509 > 1000, so every R value up to 1000 is marked in ir); s holds S(1..960) 40 fn main to int 41 r = new ulong 51 0 42 s = new ulong 961 0 43 ir = new uchar 1600 0 44 put r 1 1 45 put s 1 2 46 put ir 1 1 47 for i ulong 49 48 n = add i 2 49 v = add get r sub n 1 get s sub n 1 50 put r n v 51 put ir v 1 52 c = add get s sub n 1 1 53 while eq get ir c 1 bound 2 54 c = add c 1 55 end 56 put s n c 57 end 58 note S as the complement of R, now that R is known through 1509: the k-th unmarked integer is S(k) 59 k = ulong 0 60 c = ulong 1 61 while lt k 960 bound 1600 62 if eq get ir c 0 63 k = add k 1 64 put s k c 65 end 66 c = add c 1 67 end 68 emit first 69 for i ulong 10 70 emit sp 71 emitu get r add i 1 72 end 73 emit nl 74 cnt = new ulong 1001 0 75 ok = ulong 1 76 for i ulong 40 77 v = get r add i 1 78 if gt v 1000 79 ok = ulong 0 80 else 81 put cnt v add get cnt v 1 82 end 83 end 84 for i ulong 960 85 v = get s add i 1 86 if gt v 1000 87 ok = ulong 0 88 else 89 put cnt v add get cnt v 1 90 end 91 end 92 for i ulong 1000 93 if ne get cnt add i 1 1 94 ok = ulong 0 95 end 96 end 97 emit chk 98 if eq ok 1 99 emit yes 100 else 101 emit no 102 end 103 ret 0 104 end 105 106 {{out}} 107

108 R(1) to R(10): 1 3 7 12 18 26 35 45 56 69

109 first 40 R and first 960 S cover 1..1000 exactly once: yes

110