-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDoes it Divide_.py
More file actions
40 lines (32 loc) · 710 Bytes
/
Does it Divide_.py
File metadata and controls
40 lines (32 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def prime(n) :
# Corner cases
if (n <= 1) :
return 0
if (n <= 3) :
return 1
# This is checked so that we can skip
# middle five numbers in below loop
if (n % 2 == 0 or n % 3 == 0) :
return 0
i = 5
while(i * i <= n) :
if (n % i == 0 or n % (i + 2) == 0) :
return 0
i = i + 6
return 1
t = int(input())
for _ in range(t):
n = int(input())
x = prime(n)
if n==2:
print('NO')
elif n==1:
print('YES')
elif x==1:
print('YES')
elif x==0:
y = prime(n+1)
if y==1:
print('NO')
else:
print('YES')