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.

VivSisMMM | 164 |

d_Coder00 | 163 |

ajayjadhav35 | 153 |

Astikeysingh | 148 |

Sathvik Avasarala | 143 |

Pulkit__Sharma__ | 658 |

Anirban166 | 565 |

abducodes | 542 |

Sathvik Avasarala | 506 |

Found_me | 494 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.