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 Mar 20, 2024
1 parent f2172e6 commit 5782f66
Show file tree
Hide file tree
Showing 2 changed files with 26 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)
3 changes: 3 additions & 0 deletions bench/bench_acton.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ problems:
- name: edigits
source:
- 1.act
- name: nsieve
source:
- 1.act
- name: pidigits
source:
- 1.act
Expand Down

0 comments on commit 5782f66

Please sign in to comment.