#C3002. Sum of Prime Numbers in a Range

    ID: 46382 Type: Default 1000ms 256MiB

Sum of Prime Numbers in a Range

Sum of Prime Numbers in a Range

Given a range ([a, b]), your task is to compute the sum of all prime numbers within that range. A number (p) is considered prime if it is greater than 1 and has no divisors other than 1 and itself. You will be given multiple test cases. For each test case, print the sum of all prime numbers that lie in the interval ([a, b]).

Note: It is guaranteed that (1 \leq a \leq b \leq 10^6).

inputFormat

The first line contains an integer (T) that denotes the number of test cases. Each of the following (T) lines contains two integers (a) and (b), separated by a space, representing the inclusive range ([a, b]).

outputFormat

For each test case, output a single line containing the sum of all prime numbers within the range ([a, b]).## sample

2
10 20
15 15
60

0

</p>