A Prime Problem


Submit solution

Points: 7
Time limit: 1.0s
Python 2 3.0s
Python 3 3.0s
Memory limit: 128M

Author:
Problem type

Answer the following \(Q\) queries:

Count the number of prime numbers in the range \([A, B]\).

Input Specification

The first line of the input will contain an integer \(Q\) \((1 \le Q \le 100)\), indicating the number of queries.

The next \(Q\) lines will each contain two integers \(A_i\) and \(B_i\), where \(1 \le A_i \le B_i \le 10^6\).

Output Specification

Output \(Q\) lines, where the \(i\)-th line represents the number of prime numbers in the range \([A_i, B_i]\).

Sample Input

2
2 17
1 4

Sample Output

7
2

Sample Explanation

The \(7\) prime numbers in the given range are \(2\), \(3\), \(5\), \(7\), \(11\), \(13\), and \(17\).

The \(2\) prime numbers in the range \([1, 4]\) are \(2\) and \(3\).


Comments

There are no comments at the moment.