Baseline: tree as shared
This commit is contained in:
commit
659c03bbf8
1471 files changed
+990535
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# probe: the sieve of Eratosthenes with a List[Bool]
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: 15 [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
|
||||
def primes_below(n: Int) -> List[Int]:
|
||||
var is_prime = List[Bool]()
|
||||
for _ in range(n):
|
||||
is_prime.append(True)
|
||||
var out = List[Int]()
|
||||
for i in range(2, n):
|
||||
if is_prime[i]:
|
||||
out.append(i)
|
||||
var j = i * i
|
||||
while j < n:
|
||||
is_prime[j] = False
|
||||
j += i
|
||||
return out^
|
||||
|
||||
|
||||
def main():
|
||||
var ps = primes_below(50)
|
||||
print(len(ps), ps)
|
||||
Reference in new issue
Block a user