example/program.sieve_primes.primi
import std.math: sqrt
find_primes = (num) => {
num_list = [true] * (num + 1)
num_list[0] = num_list[1] = false
i = 2
sqrt_num = sqrt(num)
while (i <= sqrt_num) {
j = 2
while (i * j <= num) {
num_list[i * j] = false
j = j + 1
}
i = i + 1
}
result = []
for (num, tmp in enumerate(num_list)) {
if (tmp) {
result.push(num)
}
}
return result
}
x = find_primes(1_000)
print(x)