interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / sieve / .meta / example.om

25 lines · 658 bytes Raw Blame History
1note Exercism-style exercise "sieve": https://exercism.org/tracks/python/exercises/sieve
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note primes writes every prime from 2 up to and including limit (limit at most 1000) into o, in
4note increasing order, using the sieve of Eratosthenes, and returns how many it wrote.
5note Check it with: sh exercise.sh exercises/sieve
6om2
7const SMAX ulong 1001
8fn primes limit ulong o edit ulong * to ulong
9comp = new uchar SMAX 0
10k = ulong 0
11for i ulong add limit 1
12if ge i 2
13if eq get comp i 0
14put o k i
15k = add k 1
16j = mul i i
17while le j limit bound 1000
18put comp j 1
19j = add j i
20end
21end
22end
23end
24ret k
25end