Manu and The Simple Problem
Practice
0 (0 votes)
Binary search
Modular exponentiation
Sieve
Medium
Problem
58% Success 178 Attempts 30 Points 2.5s Time Limit 256MB Memory 1024 KB Max Code

Manu, the girl of confusion has a simple problem to solve but she got confused about how to solve it. Can u help her solve it?

You are given a number n. You have to find the largest prime number <= n (say a) and the smallest prime number >= n (say b).

You are supposed to find ab.

As the answer can be pretty large (even larger than Manu's Confusions:) ), print it modulo 109+7.
 

Input Format:
First line contains the number of test cases t. 
Next t lines conatins a single integer n as described in question.


Output Format:
For each test case, print a single line containing the answer
 

Constraints:
t<=107
2<= n <=9999991

 

P.S. - The test cases for the problem are too tight. Use fast I/O and all possible optimisations to get AC.

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
38 votes
Tags:
Modular ExponentiationMediumMatrix ExponentiationNumber TheoryMathematics
Points:30
32 votes
Tags:
MathematicsMediumNumber Theory
Points:30
1 votes
Tags:
Modular exponentiationMediumMath