jzakiya, you may wonder why your program eats that much memory. I had just looked at you code, and tried this: #for byt in seg[0..Kn-1]: # count the twin primes in the segment # primecnt += uint(pbits[byt]) # count the '0' bit pairs as twin primes for jj in 0 .. Kn-1: # count the twin primes in the segment primecnt += uint(pbits[seg[jj]]) $ nim c --cc:gcc --d:release --gc:none h.nim $ ./h Enter integer number: 500_000_000_000 segment has 262144 bytes and residues groups prime candidates = 133333333333; resgroups = 16666666667 create nextp[6x57081] array perform Twin Prime Segmented SoZ last segment = 75435 resgroups; segment slices = 63579 total twins = 986222314; last twin = 499999999062+/-1 total time = 205.109 secs
Seems to work now, so that part of your code seems to generate a copy of the seq for each call.