Primality Test
InterviewTime limit1sMemory limit128 MB
Decide whether each of up to 10 numbers up to 100000000 is prime and print YES or NO.
- Level
Easy3 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
An integer greater than 1 is a prime number when it has no positive divisor other than 1 and itself. The numbers 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 are all prime. A natural number that is at least 2 and is not prime, such as 4, 6, or 16, is a composite number. The number 1 is neither prime nor composite.
Decide whether a given natural number is prime.
Input
Read from standard input. The first line contains the number of test cases . Each of the next lines contains one natural number to test. The bounds are and .
Output
Write to standard output. For each test case print one line: YES when is prime, NO when it is not. There are test cases, so the program prints lines in total.