Hello, Segmented sieve of Eratosthenes used to find primes in range [a, b]Link: http://apps.topcoder.com/forums/?module=Thread&threadID=716232&start=0&mc=3 I tried implementing Segmented Sieve but i am unable to get the desired results. Problem Link: http://www.spoj.com/problems/PRIME1/ I think that problem is in segmented sieve logic or may be i have committed a mistake, and i have a doubt too regarding the provided logic, i.e.
Suppose My input is 1 10Then according to logic sqrt(b) will be 3.. That means primes will be [2,3]But i think it is wrong... About Error: On Providing This input 1 > test cases 1 10 > [a, b] And can you please explain where am i committing mistake.. asked 22 Feb '15, 03:07

You have implemented your code wrongly. Read about segmented sieve from here.. read and code it on your own! Hope it helps :) answered 22 Feb '15, 06:44
Thank You @vicky002.. :)
(22 Feb '15, 19:59)

See this explanation to get better insight, and the following code. The code is very much exactly the same way as the explanation says. The link mentioned above by @vicky002 is also good to understand. answered 22 Feb '15, 09:07
Thank You @damn_me.. :)
(22 Feb '15, 19:59)

Good Question indeed! I too was stuck in this one..Really helpful post and answers. :)