Given a number **N**, you have to find nearest prime number. If there are more then one, print the smaller one.

**Input:**

First line of input contains **T** denoting number of test cases. Only line of each test case contains one integers** N, **as described above.

**Output:**

For each test case output a single line containing one integer, the answer to the above problem.

**Constraints:**

1<= T <= 100000

2<= N <= 10^{6}

**Example:
Input:**

2

6

14

5

13

**Explanation:
Test case 1**- for 6, both 5 and 7 are at same distance, but we need to print the smaller one, so output is 5

Author: tanujyadav97

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.

mr_kksparrow | 433 |

manvirag982 | 272 |

snow_den_ | 236 |

arpit_anshuman | 228 |

Exception_404 | 220 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.