Skip to content

Latest commit

 

History

History

Count Number of Primes in Given Range

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given a range [L, R], we need to find the count of total numbers of prime numbers in the the range [L, R] where 0 <= L <= R < 10000. Consider that there are a large number of queries for different ranges.

Input : Query 1 : L = 1, R = 10
        Query 2 : L = 5, R = 10
Output : 4
         2
Explanation
Primes in the range L = 1 to R = 10 are 
{2, 3, 5, 7}. Therefore for query, answer 
is 4 {2, 3, 5, 7}.
For the second query, answer is 2 {5, 7}.