素数の列挙

とりあえずリストとかぜんぜん整備してないんで純朴に

fun is_prime:num do
    if 2 < num then
        for m in [2..num-1]
            if num % m == 0 then
                return false;
    return true;
end

for num in [2..100]
    if (is_prime:num) then
        put: num + ", ";
puts;

実行結果

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 
-> null