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/proper-divisors.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 / proper-divisors.wiki` 93 lines ยท 1711 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 col ":" 9 text most "the number in 1..20000 with the most proper divisors: " 10 text has " has " 11 text pd " proper divisors\n" 12 note nd n counts the proper divisors of n, for n up to 20000 13 global nd ulong 20001 14 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 15 fn emit a view uchar * to void 16 o = ulong 0 17 while lt o len a bound 4096 18 k = write 1 a o sub len a o 19 if le k 0 20 exit 1 21 end 22 o = add o ulong k 23 end 24 end 25 note emitu writes n in decimal; 20 digits hold every ulong 26 fn emitu n ulong to void 27 d = new uchar 20 0 28 i = ulong 20 29 v = n 30 while true bound 20 31 i = sub i 1 32 put d i uchar add rem v 10 48 33 v = div v 10 34 if eq v 0 35 break 36 end 37 end 38 emit part d i sub 20 i 39 end 40 fn main to int 41 note proper divisors of 1..10 by trial over 1..n-1 42 for i ulong 10 43 n = add i 1 44 emitu n 45 emit col 46 for j ulong i 47 d = add j 1 48 if eq rem n d 0 49 emit sp 50 emitu d 51 end 52 end 53 emit nl 54 end 55 note each d counts once for each multiple 2d, 3d, ... up to 20000; fewer than 20000 multiples per d 56 d = ulong 1 57 while le d 10000 bound 10000 58 j = mul d 2 59 while le j 20000 bound 20000 60 put nd j add get nd j 1 61 j = add j d 62 end 63 d = add d 1 64 end 65 b = ulong 1 66 for i ulong 20000 67 n = add i 1 68 if gt get nd n get nd b 69 b = n 70 end 71 end 72 emit most 73 emitu b 74 emit has 75 emitu get nd b 76 emit pd 77 ret 0 78 end 79 80 {{out}} 81

82 1:

83 2: 1

84 3: 1

85 4: 1 2

86 5: 1

87 6: 1 2 3

88 7: 1

89 8: 1 2 4

90 9: 1 3

91 10: 1 2 5

92 the number in 1..20000 with the most proper divisors: 15120 has 79 proper divisors

93