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
jukerburg10:
20190814 12:32:46
i used farmat little theorem in C ,,,getting WA ,,


akashbhalotia:
20190706 14:13:20
#JavaCodersMatter :'( 

selfcoder24:
20190611 09:03:13
Works with just fermant's with 20 iterations and by taking care of overflow during multiplications 

dkkv0000:
20190518 11:08:42
useful links to solve the problem


abhinav_kr:
20190514 09:00:56
Carmichael numbers may be giving you WA. Read this


exesharkx:
20190210 14:57:27
For Overflow use boost library :) 

manjeet_:
20180717 09:55:59
along with Fermat and Miller Rabin read this too , https://www.geeksforgeeks.org/multiplylargeintegersunderlargemodulo/ 

michulo:
20180629 15:29:54
Hey is the cluser much slower then i5 ? it takes 3 sec at my laptop and "time limit exceeded" at spoj. Is it posible ?


reinomumei:
20180605 17:40:10
first time using Miler Rabin


chetan4060:
20180525 21:38:16
both miller rabin and fermat's test works but remember for overflow of (a*b)%mod:) 
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 