Ma5termind's Birthday Party
Practice
3.1 (16 votes)
Approved
Basic programming
Easy
Math
Open
Primality test
Sieve
Problem
46% Success 12338 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Ma5termind is having his birthday this weekend. Yeah !! You all are invited . Ma5termind wants to send an invitation to those groups of people which he finds interesting. A group of N people is said to be interesting only if the number of their possible circular permutations is divisible by N. Now, Ma5termind got confused as he is having all the groups having number of people belongs to [L,R] (both inclusive). Help him in find the minimum number of invitation cards required and win yourself a chance to attend Ma5termind's birthday party .

[INPUT:]

First line of the input contains a single integer T denoting the number of test cases. First and the only line of each test case consists of two space separated integers L and R denoting the range such that N belongs to [L,R] (both inclusive).

[OUTPUT:]

Output consists of T lines each containing the answer to the corresponding test case denoting the minimum number of invitation cards required by the Ma5termind.

[CONSTRAINTS:]

T<=10^6

1<=L<=R<=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:20
114 votes
Tags:
EasyMathNumber TheoryPrimality test
Points:20
17 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyImplementationOpen
Points:20
22 votes
Tags:
ApprovedEasyMathOpenPrimality test