PON  Prime or Not
Given the number, you are to answer the question: "Is it prime?"
Solutions to this problem can be submitted in C, C++, Pascal, Perl, Python, Ruby, Lisp, Hask, Ocaml, Prolog, Whitespace, Brainf**k and Intercal only.
Input
t – the number of test cases, then t test cases follows. [t <= 500]
Each line contains one integer: N [2 <= N <= 2^631]
Output
For each test case output string "YES" if given number is prime and "NO" otherwise.
Example
Input: 5 2 3 4 5 6 Output: YES YES NO YES NO
hide comments
cake_is_a_lie:
20170222 01:11:21
@rishi_devan: We do have a deterministic primality test; google AKS primality test.


malavan:
20170110 15:58:03
Why wrong answer in Miller :( 

scorpion_ajay:
20170107 14:24:36
good question, ac in one go, 20 iterations is a good choice for almost all integers


swatantragupta:
20161223 12:38:13
nice question...miller rabin works fine ..take care of overflow while multiplication.. 

Abhishek:
20160924 18:33:02
Solved with 4 iterations of fermat's 

mkfeuhrer:
20160707 10:05:30
miller rabin accptd! prime sieve algo dint work....! yes multiplication wd mod is obvious.! 

pulkitgulati:
20160703 01:25:31
miller rabin is working fine...wa with fermat. 

harshit23897:
20160630 18:31:28
I am getting WA in both fermat and miller


mostasim:
20160518 17:08:33
why i'm getting runtime error with prime sieve algo :( 

ov3rk1ll:
20160324 10:43:47
take care of integer overflow 
Added by:  Roman Sol 
Date:  20050124 
Time limit:  21s 
Source limit:  5000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ADA95 ASM32 BASH CSHARP CLPS D ERL FORTRAN ICON JAVA JSRHINO LUA NEM NICE PHP PIKE ST 
Resource:  ZCon 2005 