Sum of Primes
Practice
4.3 (23 votes)
Easy
Number theory
Problem
78% Success 13017 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Let's define the function \(F(l,r)\) :

\( F(l,r) \) = \( \sum x\), \(\forall x \), where x is a prime number between l and r inclusive.

In Short, for each function \(F(l,r)\) you need to find the summation of all primes between the integers l and r inclusive.

Now, you shall be given multiple queries. In each query, you shall be given the integers l and r and you need to find the result of the function \(F(l,r)\)

Input Format:

The first line contains a single integer N denoting the number of queries. Each of the next N lines contains two integers l and r denoting the parameters of the \(i^{th}\) query.

Output Format:

For each query, output the answer on a new line.

Constraints

For \(30\) Points:

\( 1 \leq N \leq 1000 \)

\( 1 \leq l \leq r \leq 1000 \)

For the next \(70\) Points:

\( 1 \leq N \leq 5*10^5 \)

\( 1 \le l \le r \le 10^6 \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
19 votes
Tags:
AlgorithmsEuler's totient functionGreatest common divisorMathNumber TheorySieve
Points:30
10 votes
Tags:
AlgorithmsMathNumber TheoryNumber theory
Points:30
12 votes
Tags:
EasyMathNumber TheoryNumber theory