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/count-in-factors.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 / count-in-factors.wiki` 106 lines ยท 1801 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 x " x " 8 text eqs " = " 9 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 10 fn emit a view uchar * to void 11 o = ulong 0 12 while lt o len a bound 4096 13 k = write 1 a o sub len a o 14 if le k 0 15 exit 1 16 end 17 o = add o ulong k 18 end 19 end 20 note emitu writes n in decimal; 20 digits hold every ulong 21 fn emitu n ulong to void 22 d = new uchar 20 0 23 i = ulong 20 24 v = n 25 while true bound 20 26 i = sub i 1 27 put d i uchar add rem v 10 48 28 v = div v 10 29 if eq v 0 30 break 31 end 32 end 33 emit part d i sub 20 i 34 end 35 note prime factors in ascending order by trial division; 1 is shown as itself 36 note bound: each pass divides v or steps d, and d * d <= v; for the inputs here d never passes 6857 37 fn tell n ulong to void 38 emitu n 39 emit eqs 40 if eq n 1 41 emitu 1 42 emit nl 43 ret 44 end 45 v = n 46 d = ulong 2 47 f = ulong 0 48 while le mul d d v bound 999999 49 if eq rem v d 0 50 if gt f 0 51 emit x 52 end 53 emitu d 54 f = add f 1 55 v = div v d 56 else 57 d = add d 1 58 end 59 end 60 if gt v 1 61 if gt f 0 62 emit x 63 end 64 emitu v 65 end 66 emit nl 67 end 68 fn main to int 69 for i ulong 25 70 tell add i 1 71 end 72 for i ulong 13 73 tell add 2144 i 74 end 75 tell `600851475143` 76 tell `1000000000000` 77 ret 0 78 end 79 80 {{out}} 81

82 1 = 1

83 2 = 2

84 3 = 3

85 4 = 2 x 2

86 5 = 5

87 6 = 2 x 3

88 7 = 7

89 8 = 2 x 2 x 2

90 9 = 3 x 3

91 10 = 2 x 5

92 11 = 11

93 12 = 2 x 2 x 3

94 13 = 13

95 14 = 2 x 7

96 15 = 3 x 5

97 ...

98 2151 = 3 x 3 x 239

99 2152 = 2 x 2 x 2 x 269

100 2153 = 2153

101 2154 = 2 x 3 x 359

102 2155 = 5 x 431

103 2156 = 2 x 2 x 7 x 7 x 11

104 `600851475143` = 71 x 839 x 1471 x 6857

105 `1000000000000` = 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 x 5 x 5 x 5 x 5 x 5 x 5 x 5 x 5 x 5 x 5 x 5 x 5

106