make sieve of eratosthenes efficient

The problem with the present implementation is that we are deleting a log of items from the list which makes this very inefficient. 
The example implementation I provided will return primes upto 1 million in less than half second while the present implementation takes more than 1 second for primes upto 1000