-->
当前位置:首页 > 题库

PROGRAMMING:Judge prime

Luz5年前 (2021-05-10)题库668
Determine whether a given positive integer is prime
###Input format:
Input a positive integer n (≤ 10) in the first line, and then n lines, each line gives a positive integer less than 1000000 that needs to be judged
###Output format:
For each positive integer that needs to be judged, if it is a prime, output yes in one line, otherwise output No
###Input example:
Here is a set of inputs. For example:
```in
two
eleven
one hundred and eleven
```
###Output example:
The corresponding output is given here. For example:
```out
Yes
No
```







answer:If there is no answer, please comment
```
n=int(input())
for i in range(n):
p=int(input())
if p==1:
print('No')
else:
if [j for j in range(1,p+1) if p%j==0]==[1,p]:
print('Yes')
else:
print('No')
```