Python3 代码
import math
n = int(input())
for i in range(n):
x = int(input())
s = math.floor(math.sqrt(x))
p = True
for j in range (2, s+1):
if x % j == 0:
p = False
break
if p:
print (x, "is prime")
else:
print (x, "is not prime")