Consider Ø(n) as the Euler Totient Function for n. You will be given a positive integer **N** and you have to find the smallest positive integer** n**, n <= N for which the ratio n/Ø(n) is maximized.

**Input**:

First line of input consist of a single integer T denoting the total number of test case. Then T test cases follow. Each test case consists of a line with a positive integer N.

**Output**:

For each test case, in a new line print the smallest value of n, n <= N for which the ratio n/Ø(n) is maximized.

**Constraints:**

1<=T<=500

1<=N<=10^{12}

**Example:
Input:**

2

6

50

**Output:**

6

30

**Explanation:**

**First test Case**

For n = 1, 2, 3, 4, 5 and 6 the values of the ratio are 1, 2, 1.5, 2, 1.25 and 3 respectively. The maximum is obtained at 6.

**Second test Case**

For n = 1 to 50, the maximum value of the ratio is 3.75 which is obtained at n = 30.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

hardikJain5 | 234 |

CodeBuddy | 196 |

bhatabhi554 | 172 |

Akkki111 | 169 |

clone | 166 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1127 |

mazumderrohit8 | 1108 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4587 |

Quandray | 4444 |

Login to report an issue on this page.