Given T (1 ≤ T ≤ 10000) integers N (1 ≤ N < 2^16), output "1" if each one is prime, and "0" otherwise.
Remember: an integer is prime iff (if and only if) it has exactly two divisors: 1 and N.
Line 1: one integer T
Lines 2..T+1: one integer N
Lines 1..T: One integer "1" or "0" denoting whether N is prime. Output "1" if N is prime, and "0" otherwise.
3 1 2 3
0 1 1
Point Value: 4
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 27, 2008
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Look at the variable names you are using on lines 2, 5, 9. Then try rubber-ducking your code. What actually happens when it breaks out of the for loop (not what you intended, I assume)
"Remember: an integer is prime iff (if and only if) it has exactly two divisors: 1 and N."
I think it should be "if (if and only if) it has exactly two divisors: 1 and N." and not "iff (if and only if) it has exactly two divisors: 1 and N.".
since having two divisors is sufficient and necessary for being prime, iff is the correct term here
edit: read here
does it not allow modules?
wat does this mean:.../?
does anyone know a faster way to do prime? Mine keeps saying time limit exceeded so i need some help.
You can make your program faster by noticing that when you check whether a number is prime, you only need to test for factors up to the square root of the number.
And what does: .../ mean? (When you get answer wrong and you click details, or your output)