Alice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice says out an integer and Bob has to say whether the number is prime or not. Bob as usual knows the logic but since Alice doesn't give Bob much time to think, so Bob decides to write a computer program.
Help Bob accomplish this task by writing a computer program which will calculate whether the number is prime or not .

------ Input ------ 

The first line of the input contains an integer T, the number of testcases. T lines follow. 
Each of the next T lines contains an integer N which has to be tested for primality. 

------ Output ------ 

For each test case output in a separate line, "yes" if the number is prime else "no."

------ Constraints ------ 
   
$1 ≤ T ≤ 20$
$1 ≤ N ≤ 100000$

----- Sample Input 1 ------ 
5

23

13

20

1000

99991
----- Sample Output 1 ------ 
yes

yes

no

no

yes

Difficulty: EASY
Tags: Number theory

Mathematics

Starter code:

Solutions:
n = int(input())
for i in range(n):
	x = int(input())
	if x == 1:
		print('no')
	else:
		for i in range(2, x // 2 + 1):
			if x % i == 0:
				print('no')
				break
		else:
			print('yes')


for i in range(int(input())):
	n = int(input())
	c = 0
	for j in range(1, n + 1):
		if n % j == 0:
			c += 1
	if c == 2:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	n = int(input())
	count = 0
	x = 1
	while x <= n:
		if n % x == 0:
			count += 1
			x += 1
		else:
			count += 0
			x += 1
	if count == 2:
		print('yes')
	else:
		print('no')


def prime(n):
	if n == 1:
		return 0
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return 0
	return 1
for _ in range(int(input())):
	if prime(int(input())):
		print('yes')
	else:
		print('no')


def is_prime(n):
	if n <= 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
t = int(input())
for i in range(t):
	n = int(input())
	if is_prime(n):
		print('yes')
	else:
		print('no')


from math import sqrt

def isPrime(n):
	if n == 1:
		return False
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
t = int(input())
for i in range(t):
	n = int(input())
	if isPrime(n):
		print('yes')
	else:
		print('no')


import math
t = int(input())
for t1 in range(t):
	n = int(input())
	sn = int(math.sqrt(n)) + 1
	c = 0
	if n == 2:
		print('yes')
	elif n == 1:
		print('no')
	else:
		for i in range(2, sn):
			if n % i == 0:
				c += 2
				print('no')
				break
		if c == 0:
			print('yes')


t = int(input())
for _ in range(t):
	n = int(input())
	c = 0
	i = 1
	while i <= n:
		if n % i == 0:
			c += 1
		i += 1
	if c == 2:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	n = int(input())
	count = 0
	if n == 2:
		print('yes')
	elif n <= 1:
		print('no')
	else:
		for i in range(2, int(n / 2 + 1)):
			if n % i == 0:
				count = 1
				break
		if count == 1:
			print('no')
		else:
			print('yes')


for t in range(int(input())):
	n = int(input())
	c = 0
	for i in range(2, n):
		if n % i == 0:
			c = 1
			break
	if c == 1 or n == 1:
		print('no')
	else:
		print('yes')


T = int(input())
for i in range(T):
	n = int(input())
	x = 0
	for j in range(1, n + 1):
		if n % j == 0:
			x = x + 1
	if x == 2:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	N = int(input())
	l = 0
	for j in range(1, N + 1):
		if N % j == 0:
			l = l + 1
	if l == 2:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	x = int(input())
	count = 1
	for j in range(2, x + 1):
		if x % j == 0:
			count = count + 1
	if count == 2:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	n = int(input())
	if n < 2 or (n != 2 and n % 2 == 0):
		print('no')
	else:
		for j in range(2, int(n ** 0.5) + 1):
			if n % j == 0:
				print('no')
				break
		else:
			print('yes')


import math
t = int(input())
for i in range(t):
	n = int(input())
	if n == 0 or n == 1:
		print('no')
	elif n == 2 or n == 3:
		print('yes')
	else:
		for i in range(2, round(math.sqrt(n) + 1)):
			if n % i == 0:
				print('no')
				break
		else:
			print('yes')


T = int(input())
for i in range(T):
	num = int(input())
	l = 0
	for j in range(1, num + 1):
		if num % j == 0:
			l = l + 1
	if l == 2:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	n = int(input())
	f = 0
	for i in range(2, n // 2 + 1):
		if n % i == 0:
			f = 1
			break
	if f == 0 and n != 1:
		print('yes')
	else:
		print('no')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print('no')
	else:
		r1 = int(math.sqrt(n))
		c = 0
		for i in range(1, r1 + 1):
			if n % i == 0:
				c = c + 2
				if c > 2:
					break
		if c == 2:
			print('yes')
		else:
			print('no')


import math
T = int(input())
for _ in range(T):
	N = int(input())
	if N == 1:
		print('no')
	else:
		upper_limit = int(math.sqrt(N)) + 1
		for i in range(2, N):
			if N % i == 0:
				print('no')
				break
			else:
				continue
		else:
			print('yes')


t = int(input())
for i in range(t):
	a = 0
	n = int(input())
	for j in range(1, n + 1):
		if n % j == 0:
			a = a + 1
	if a == 2:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	x = int(input())
	flag = True
	if x == 1:
		print('no')
	elif x > 1:
		for i in range(2, x):
			if x % i == 0:
				flag = False
		if flag:
			print('yes')
		else:
			print('no')


T = int(input())
for i in range(T):
	N = int(input())
	flag = 0
	if N == 1:
		print('no')
	elif N > 1:
		for i in range(2, N):
			if N % i == 0:
				flag += 1
				break
		if flag == 0:
			print('yes')
		else:
			print('no')


import math
for i in range(0, int(input())):
	n = int(input())
	a = int(math.sqrt(n))
	if n > 1:
		t = 0
		for j in range(2, a + 1):
			if n % j == 0:
				print('no')
				t = 1
				break
			else:
				continue
		if t == 0:
			print('yes')
	else:
		print('no')


def prime(n):
	if n == 1:
		return False
	for i in range(2, n):
		if n % i == 0:
			return False
	else:
		return True
for _ in range(int(input())):
	a = int(input())
	if prime(a):
		print('yes')
	else:
		print('no')


n = int(input())
for i in range(n):
	x = int(input())
	f = 1
	for i in range(2, x):
		if x % i == 0:
			f = 0
	if f == 0 or x == 1:
		print('no')
	else:
		print('yes')


import math
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print('no')
		continue
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			print('no')
			break
	else:
		print('yes')


for _ in range(int(input())):
	num = int(input())
	l = 0
	for j in range(1, num + 1):
		if num % j == 0:
			l = l + 1
	if l == 2:
		print('yes')
	else:
		print('no')


def prime(n):
	c = 0
	for i in range(2, n // 2):
		if n % i == 0:
			c += 1
	if c != 0 or n == 0 or n == 1:
		return 'no'
	else:
		return 'yes'
for i in range(int(input())):
	n = int(input())
	print(prime(n))


import math
n = int(input())
for i in range(n):
	p = int(input())
	f = 0
	for j in range(2, int(math.sqrt(p)) + 1):
		if p % j == 0:
			f = 1
			break
	if f == 1 or p == 1:
		print('no')
	else:
		print('yes')


t = int(input())
while t > 0:
	n = int(input())
	b = False
	if n > 1:
		b = True
	for i in range(2, n // 2 + 1):
		if n % i == 0:
			b = False
			break
	if b:
		print('yes')
	else:
		print('no')
	t -= 1


for i in range(int(input())):
	num = int(input())
	if num <= 1:
		print('no')
	else:
		for n in range(2, int(num ** 0.5) + 1):
			if num % n == 0:
				print('no')
				break
		else:
			print('yes')


def isPrime(n):
	if n <= 1:
		return False
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
test_Case = int(input())
while test_Case > 0:
	user_input = int(input())
	print('yes') if isPrime(user_input) else print('no')
	test_Case -= 1


for i in range(int(input())):
	a = int(input())
	(c, d) = (1, 0)
	while c <= a:
		if a % c == 0:
			d += 1
		c += 1
	print('yes') if d == 2 else print('no')


from math import sqrt
t = int(input())
while t > 0:
	f = 0
	t = t - 1
	n = int(input())
	for i in range(2, n + 1):
		if n % i == 0:
			f = f + 1
	if f == 1:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	N = int(input())
	sum = 0
	i = 1
	while i <= N:
		if N % i == 0:
			sum = sum + 1
		i = i + 1
	if sum == 2:
		print('yes')
	else:
		print('no')


T = int(input())
for i in range(T):
	a = int(input())
	no = 0
	for j in range(2, a):
		if a % j == 0:
			no = 1
	if no == 1 or a == 1:
		print('no')
	else:
		print('yes')


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print('no')
	else:
		flag = 'yes'
		for i in range(2, n):
			if i * i > n:
				break
			if n % i == 0:
				flag = 'no'
		print(flag)


import math
for t in range(int(input())):
	n = int(input())
	c = 0
	k = 0
	if n <= 1:
		print('no')
		k = 1
	if k == 0:
		for i in range(2, n):
			v = i * i
			if v <= n:
				if n % i == 0:
					c = 1
					print('no')
					break
			else:
				break
		if c == 0:
			print('yes')


t = int(input())
while t > 0:
	t = t - 1
	a = int(input())
	f = 1
	for i in range(2, a):
		if a % i == 0:
			f = 0
			break
	if f == 0 or a == 1:
		print('no')
	else:
		print('yes')


import math as m
t = int(input())
for i in range(t):
	c = 0
	x = int(input())
	if x == 1:
		print('no')
	else:
		for j in range(2, int(m.sqrt(x)) + 1):
			if x % j == 0:
				c += 1
		if c > 0:
			print('no')
		else:
			print('yes')