Skip to content

Commit

Permalink
Add Acton nsieve
Browse files Browse the repository at this point in the history
It's fairly slow and the string formatting is just horrible, but it works!
  • Loading branch information
plajjan committed Jun 16, 2023
1 parent e18226d commit 38f4a57
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bench/algorithm/nsieve/1.act
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env runacton

def nsieve(n: int):
count = 0
flags = [True] * n
for i in range(2, n, 1):
if flags[i]:
count += 1
for j in range(i, n, i):
flags[j] = False
n_s = ""
for j in range(0, (8-(len(str(n)))), 1):
n_s += " "
c_s = ""
for j in range(0, (8-(len(str(count)))), 1):
c_s += " "
print("Primes up to %s%d %s%d" % (n_s, n, c_s, count))

actor main(env):
n = 4 if len(env.argv) < 2 else int(env.argv[1])
for i in range(0, 3, 1):
nsieve(10000 << (n - i))
await async env.exit(0)

0 comments on commit 38f4a57

Please sign in to comment.