6 - The Infinite Prime
Time limit: 1000 ms
Memory limit: 250 MB

Prime numbers are the building blocks of the number system. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. As numbers grow larger, it becomes computationally challenging to check whether a number is prime or not, especially when dealing with extremely large numbers.

Your task is to help mathematicians check whether a given number is prime. You will be given multiple numbers in the input, and for each number, you need to determine whether it is a prime number or not.

Input
  • The first line of input contains a single integer T, the number of test cases.

  • The next T lines contain a single integer N each, the number you need to check for primality.

Output
  • For each test case, print YES if the number is prime.

  • Otherwise, print NO.

Constraints
  • 1 <= T <= 104

  • 2 <= N <= 1018

Example Input Example Output
5
2
17
100
999999937
100000000000000003
YES
YES
NO
YES
YES

Sign in to Submit