In your code `a` should be passed as parameter because the result is otherwise 
"escaping".

At the end of the function, the GC is allowed to collect and deallocate the 
sequence because no variables hold on to it (it was local).

That will make your result pointer points to invalid data.

Regarding Sieve of Eratosthenes I have an [implementation 
here](https://github.com/mratsim/number-theory/blob/b529843c8970b1d69ecfeb30b238f4b4525895e8/src/primes.nim)
 that uses a bitvector and should be significantly faster. 

Reply via email to