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/amicable-pairs.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 / amicable-pairs.wiki` 74 lines ยท 1368 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 note ds n is the sum of the proper divisors of n, for n below 20000 9 global ds ulong 20000 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 each i adds itself to its multiples 2i, 3i, ... below 20000; fewer than 20000 multiples per i 37 fn sieve to void 38 i = ulong 1 39 while lt i 10000 bound 10000 40 j = mul i 2 41 while lt j 20000 bound 20000 42 put ds j add get ds j i 43 j = add j i 44 end 45 i = add i 1 46 end 47 end 48 fn main to int 49 sieve 50 for n ulong 20000 51 m = get ds n 52 if and gt m n lt m 20000 53 if eq get ds m n 54 emitu n 55 emit sp 56 emitu m 57 emit nl 58 end 59 end 60 end 61 ret 0 62 end 63 64 {{out}} 65

66 220 284

67 1184 1210

68 2620 2924

69 5020 5564

70 6232 6368

71 10744 10856

72 12285 14595

73 17296 18416

74