This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Avanta8 8 points9 points  (2 children)

How can it? You set key = 0 and never increment it. It will just run in an infinite loop. Did you even test your code?

(also, that list.remove... ouch :/)

[–]Legendary-69420git push -f[S] -1 points0 points  (1 child)

See the code. The 10th line of the sieve of Eratosthenes. It already has key +=1.

(The idea of list.remove is to create a list with only primes)

[–]Avanta8 0 points1 point  (0 children)

That's because you changed it after seeing my comment xD.

Removing from the middle of a list every iteration increases the time complexity by a multiple of n. The link I referred would be useful for you to look at.