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/almost-prime.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 / almost-prime.wiki` 83 lines ยท 1544 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 kk "k = " 9 text col ":" 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 k-almost prime has exactly k prime factors counted with multiplicity 37 fn bigo n ulong to ulong 38 v = n 39 d = ulong 2 40 k = ulong 0 41 while le mul d d v bound 64 42 if eq rem v d 0 43 k = add k 1 44 v = div v d 45 else 46 d = add d 1 47 end 48 end 49 if gt v 1 50 k = add k 1 51 end 52 ret k 53 end 54 note bound: the 10th 5-almost prime is 176, so no list needs more than 200 candidates 55 fn main to int 56 for j ulong 5 57 k = add j 1 58 emit kk 59 emitu k 60 emit col 61 c = ulong 0 62 n = ulong 2 63 while lt c 10 bound 200 64 if eq bigo n k 65 emit sp 66 emitu n 67 c = add c 1 68 end 69 n = add n 1 70 end 71 emit nl 72 end 73 ret 0 74 end 75 76 {{out}} 77

78 k = 1: 2 3 5 7 11 13 17 19 23 29

79 k = 2: 4 6 9 10 14 15 21 22 25 26

80 k = 3: 8 12 18 20 27 28 30 42 44 45

81 k = 4: 16 24 36 40 54 56 60 81 84 88

82 k = 5: 32 48 72 80 108 112 120 162 168 176

83