interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / prime-factors / .meta / example.om

25 lines · 590 bytes Raw Blame History
1note Exercism-style exercise "prime-factors": https://exercism.org/tracks/python/exercises/prime-factors
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note factors writes the prime factors of value into o, smallest first and with repetition, and
4note returns how many it wrote.
5note Check it with: sh exercise.sh exercises/prime-factors
6om2
7fn factors value ulong o edit ulong * to ulong
8n = value
9k = ulong 0
10d = ulong 2
11while le mul d d n bound 999999
12if eq rem n d 0
13put o k d
14k = add k 1
15n = div n d
16else
17d = add d 1
18end
19end
20if gt n 1
21put o k n
22k = add k 1
23end
24ret k
25end