Re: [algogeeks] Sieve

2012-12-21 Thread Arman Kamal
Try taking the sqrt(N) outside the for loop. I believe it is executing every time the condition is being checked. That should do. On Thu, Dec 20, 2012 at 12:09 PM, atul anand wrote: > i had implemented Sieve of Eratosthenes long time back... > what i did was the following :- > say N is the range

Re: [algogeeks] Sieve

2012-12-19 Thread atul anand
i had implemented Sieve of Eratosthenes long time back... what i did was the following :- say N is the range and we want to find all prime number within this range. take size of temp array[] to half = N/2...as we only care of odd numbers.Prime number 2 can be handled explicitly. run outer loop for

Re: [algogeeks] Sieve

2012-12-08 Thread majeti dinesh
To deal with multiples of 2 (only), you can refer the book Parallel Programming in C With Mpi and Openmp - Michael Jay Quinn There he also mentions about cache optimizatoin. On Sat, Dec 8, 2012 at 2:44 AM, Don wrot

[algogeeks] Sieve

2012-12-07 Thread Don
I know that the Sieve of Eratosthenes is a fast way to find all prime numbers in a given range. I noticed that one implementation of a sieve spends a lot of time marking multiples of small primes as composite. For example, it takes 1000 times as long to mark off all of the multiples of five as it t