3 ms·
Here's my Python version. Same thing, using slice-skip addressing to replace the inner loop. n=1000000 isPrime = [True] * n for i in xrange(2,int(n
by dahart 9y ago
Here's my Python version. Same thing, using slice-skip addressing to replace the inner loop.
n=1000000
isPrime = [True] * n
for i in xrange(2,int(n**0.5)+1):
if isPrime[i]: isPrime[i*i::i] = [False] * ((n-i*i-1)/(i)+1)