pocketlang/tests/benchmark/primes/primes.pk
2021-06-10 23:12:04 +05:30

19 lines
301 B
Plaintext

from lang import clock
def is_prime(n)
if n < 2 then return false end
for i in 2..n
if n % i == 0 then return false end
end
return true
end
start = clock()
N = 30000; primes = []
for i in 0..N
if is_prime(i)
list_append(primes, i)
end
end
print("elapsed:", clock() - start, "s")