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/pernicious-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 / pernicious-numbers.wiki` 88 lines ยท 1721 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 pernicious numbers:" 9 text range "pernicious numbers from `888888877` to `888888888`:" 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 fn popc n ulong to ulong 37 c = ulong 0 38 v = n 39 while gt v 0 bound 64 40 c = add c and v 1 41 v = shr v 1 42 end 43 ret c 44 end 45 note a pernicious number has a prime population count; counts here are at most 30, so trial division is enough 46 fn isprime n ulong to bool 47 if lt n 2 48 ret false 49 end 50 d = ulong 2 51 while le mul d d n bound 8 52 if eq rem n d 0 53 ret false 54 end 55 d = add d 1 56 end 57 ret true 58 end 59 fn main to int 60 emit first 61 c = ulong 0 62 n = ulong 1 63 while lt c 25 bound 100 64 if isprime popc n 65 emit sp 66 emitu n 67 c = add c 1 68 end 69 n = add n 1 70 end 71 emit nl 72 emit range 73 for i ulong 12 74 n = add `888888877` i 75 if isprime popc n 76 emit sp 77 emitu n 78 end 79 end 80 emit nl 81 ret 0 82 end 83 84 {{out}} 85

86 first 25 pernicious numbers: 3 5 6 7 9 10 11 12 13 14 17 18 19 20 21 22 24 25 26 28 31 33 34 35 36

87 pernicious numbers from `888888877` to `888888888`: `888888877` `888888878` `888888880` `888888883` `888888885` `888888886`

88