Micro and Prime Prime
Practice
3.8 (525 votes)
Approved
Data structures
Easy
Hiring
Sieve
Problem
75% Success 15511 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Micro just learned about prime numbers. But he quickly got bored of them, so he defined a new kind of numbers and called them Prime Prime Numbers. A number X is Prime Prime if number of prime numbers from 1 to X (inclusive) are prime. Now he wants to find out the number of Prime Prime numbers from L to R (inclusive). Help Micro with it.

Input:
First line consists of a single integer T denoting number of test cases
Following T lines consists of two space separated integers denoting L and R

Output:
Print the number of Prime Prime Numbers for each between L and R for each test case in a new line.

Constraints:
1≤T≤105
1≤L,R≤106

Sample Input
2
3 10
4 12
Sample Output
4
5
Code Editor

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Submissions
Please login to view your submissions
Similar Problems
Points:20
17 votes
Tags:
EasyGrammar-VerifiedMathNumber TheoryPrimality testPrime number
Points:20
17 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyImplementationOpen
Points:20
52 votes
Tags:
ApprovedEasyMathOpenPrimality test
Editorial

Login to unlock the editorial