Last active
August 24, 2017 07:51
-
-
Save Yardanico/bc45e9fda1b597e10ac6c87f7ec1c8d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compile with -d:release --noMain --gc:none | |
proc printf(fmt: cstring) {.importc, varargs.} | |
proc `[]=`*[Idx, T](a: var array[Idx, T], b: T) = | |
## Sets all values in an array to b | |
for i in 0..<a.len: | |
a[i] = b | |
var flags: array[8191, bool] | |
proc main*(): cint {.exportc, cdecl.} = | |
printf("10 iterations\n"); | |
var count = 0 | |
for iter in 1..11: | |
count = 0 | |
flags[] = true | |
for i in 0..<flags.len: | |
if flags[i]: | |
let prime = i + i + 3 | |
var k = i + prime | |
while k < flags.len: | |
flags[k] = false | |
k += prime | |
inc count | |
printf("%d primes\n", count) | |
return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment