interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / si / rosetta / exercises / armstrong-numbers / .meta / example.om

28 lines · 579 bytes Raw Blame History
1note Exercism-style exercise "armstrong-numbers": https://exercism.org/tracks/python/exercises/armstrong-numbers
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note Return true when n equals the sum of its digits, each raised to the number of digits.
4note Check it with: sh exercise.sh exercises/armstrong-numbers
5om2
6fn armstrong n ulong to bool
7k = ulong 0
8v = n
9while true bound 20
10k = add k 1
11v = div v 10
12if eq v 0
13break
14end
15end
16s = ulong 0
17v = n
18for i ulong k
19d = rem v 10
20p = ulong 1
21for j ulong k
22p = mul p d
23end
24s = add s p
25v = div v 10
26end
27ret eq s n
28end