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^63-1]

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
Alien: 2013-03-13 06:11:35

GOT AC in 0.13 SEC, whereas time-limit is 21 sec

shreyash pandey: 2013-01-22 07:20:18

python nails this question :)

gourav: 2012-12-28 08:09:28

just hats off to this qstn!! if one has done this qstn, he can play with any prime number afterwards.. just one thing changed in my first code for this qstn.. got AC !! haha.. :-)

Last edit: 2012-12-28 08:09:44
god_father: 2012-12-23 18:55:56

really very good question learn a lot....
need 2 iterations of little fermit theorm.

Akb: 2012-12-21 01:48:32

got AC in 0.22 sec, Time Limit is 21 sec...!! :D

Erik Lonèarek: 2012-12-09 09:27:35

@himanshu sahu - TLE stands for Time Limit Exceeded, which means your program is too slow for this problem. Limit is 21 seconds but test cases are very very large.

jkp: 2012-12-06 08:02:36

my program is working in ideone.com but it gives TLE...........why???????

!!***Still-Fattu***!!: 2013-02-24 22:39:57

GADIYA THA......

Aditya Bahuguna: 2013-02-24 22:39:51


Last edit: 2012-10-29 18:03:15
Atul Kumar Verma: 2012-09-20 14:52:30

i am getting wrong answer. my program is fairly working in all cases. any special cases to check?


Added by:Roman Sol
Date:2005-01-24
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 JS-RHINO LUA NEM NICE PHP PIKE ST
Resource:ZCon 2005