PAGAIN  Prime Again
English  Vietnamese 
In this problem, you have to find the nearest prime number smaller than N. (3 <= N <= 2^32)
Input
The first line contains an integer T specifying the number of test cases. (T <= 10000)
T lines follow, each line contains an integer N.
Output
For each test case, output the result on one line.
Example
Input: 3 5 10 17 Output: 3 7 13
hide comments
akt_1998:
20170424 18:12:51
Sieve :)


anurag44:
20170417 23:07:37
Today I learnt following things about C++ :


shubham2305:
20170417 21:45:34
unsigned int AC long long int TLE


Sarthak Munshi:
20160608 15:20:02
10 TLEs and ongoing using MillerRabin . No idea how to proceed from hereon . Last edit: 20160612 18:35:51 

GAURAV CHANDEL:
20160224 12:10:51
Rabin miller will do it .. 

Archit Gupta:
20160220 16:40:54
Lot of TLE even after sieve,miller rabin and fermat please help


Mukul Chandel:
20151025 16:25:02
people using miller rabbin and getting TLE make sure you use UNSIGNED long long datatype. cost me 2 TLE's. Last edit: 20151027 04:16:13 

kuhan26:
20150929 16:23:21
Fermat's theorem giving TLE :/


Ayur Jain:
20150621 10:55:49
MillerRabin/Segmented Prime Sieve .. Everything is giving TLE! :/ I think requires too much of constant and data types optimisation. 

_R0b_:
20150427 21:48:12
sieve :) 
Added by:  Race with time 
Date:  20081225 
Time limit:  0.620s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 