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

83 deficient: 15043

84 perfect: 4

85 abundant: 4953

86