The smallest number

2.7

3 votes
, binary search algorithm, mathamatics, Basic Math, easy, Mathematics, mathematics, basic math, Math
Problem

Consider the following information:

  • If the number of integers that divide a number N is even, then P(N) =0. 
  • If the number of integers that divide a number N is odd, then P(N) = 1.

Task

Now, you are given a number X.

Your task is to determine the smallest number Y such that Y>X and P(Y)P(X).

Input format

  • The first line contains T denoting the number of test cases.
  • The first line of each test case contains X.

Output format

For each test case, print the smallest number Y such that Y>X and P(Y)P(X) in a new line. 

Constraints
1T105
1X108

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The number of integers that divide a number  is 2 (1,3) which is even, therefore P(3) = 0
The number of integers that divide a number is 3 (1,2,4) which is odd, therefore P(4) = 1

As P(3)P(4)

Hence, the smallest number greater than 3 satisfying the provided condition is 4. 

Editor Image

?