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-mv/blob/main/si/rosetta/exercises/perfect-numbers/.meta/example.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / exercises / perfect-numbers / .meta / example.om` 32 lines ยท 687 bytes Raw Blame History 1 note Exercism-style exercise "perfect-numbers": https://exercism.org/tracks/python/exercises/perfect-numbers 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note classify compares n with its aliquot sum (the sum of its divisors other than n): 1 perfect 4 note (equal), 2 abundant (greater), 3 deficient (smaller), 0 when n is not a positive integer. 5 note Check it with: sh exercise.sh exercises/perfect-numbers 6 om2 7 fn classify n long to int 8 if le n 0 9 ret 0 10 end 11 s = long 0 12 d = long 1 13 while le mul d d n bound 999999 14 if eq rem n d 0 15 if ne d n 16 s = add s d 17 end 18 e = div n d 19 if and ne e d ne e n 20 s = add s e 21 end 22 end 23 d = add d 1 24 end 25 if eq s n 26 ret 1 27 end 28 if gt s n 29 ret 2 30 end 31 ret 3 32 end