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/ludic-numbers.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 / ludic-numbers.wiki` 116 lines ยท 2517 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 "first 25 ludic numbers:" 9 text upto "ludic numbers <= 1000: " 10 text tfrom "2000th to 2005th ludic numbers:" 11 text trip "ludic triplets (x, x+2, x+6) below 250:" 12 text lp " (" 13 text cm ", " 14 text rp ")" 15 note the sieve runs on 2..21999; the 2005th ludic number, 21511, is below that limit, and every ludic number 16 note found is final because removing every k-th survivor never touches the survivors in front of it 17 global ls ulong 22000 18 global lu ulong 22000 19 global isl uchar 22000 20 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 21 fn emit a view uchar * to void 22 o = ulong 0 23 while lt o len a bound 4096 24 k = write 1 a o sub len a o 25 if le k 0 26 exit 1 27 end 28 o = add o ulong k 29 end 30 end 31 note emitu writes n in decimal; 20 digits hold every ulong 32 fn emitu n ulong to void 33 d = new uchar 20 0 34 i = ulong 20 35 v = n 36 while true bound 20 37 i = sub i 1 38 put d i uchar add rem v 10 48 39 v = div v 10 40 if eq v 0 41 break 42 end 43 end 44 emit part d i sub 20 i 45 end 46 note round: the first survivor k is ludic; it and every k-th survivor after it (positions 0, k, 2k, ...) go 47 note bound: each round removes at least one survivor, so at most 21998 rounds over at most 21998 survivors 48 fn main to int 49 n = ulong 0 50 for i ulong 21998 51 put ls i add i 2 52 n = add n 1 53 end 54 put lu 0 1 55 put isl 1 1 56 c = ulong 1 57 while gt n 0 bound 22000 58 k = get ls 0 59 put lu c k 60 put isl k 1 61 c = add c 1 62 m = ulong 0 63 for i ulong n 64 if ne rem i k 0 65 put ls m get ls i 66 m = add m 1 67 end 68 end 69 n = m 70 end 71 emit first 72 for i ulong 25 73 emit sp 74 emitu get lu i 75 end 76 emit nl 77 emit upto 78 m = ulong 0 79 for i ulong c 80 if le get lu i 1000 81 m = add m 1 82 end 83 end 84 emitu m 85 emit nl 86 emit tfrom 87 for i ulong 6 88 emit sp 89 emitu get lu add 1999 i 90 end 91 emit nl 92 emit trip 93 for x ulong 244 94 if eq get isl x 1 95 if and eq get isl add x 2 1 eq get isl add x 6 1 96 emit lp 97 emitu x 98 emit cm 99 emitu add x 2 100 emit cm 101 emitu add x 6 102 emit rp 103 end 104 end 105 end 106 emit nl 107 ret 0 108 end 109 110 {{out}} 111

112 first 25 ludic numbers: 1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107

113 ludic numbers <= 1000: 142

114 2000th to 2005th ludic numbers: 21475 21481 21487 21493 21503 21511

115 ludic triplets (x, x+2, x+6) below 250: (1, 3, 7) (5, 7, 11) (11, 13, 17) (23, 25, 29) (41, 43, 47) (173, 175, 179) (221, 223, 227) (233, 235, 239)

116