L1-028 判断素数 python

python 实现

import math

num=int(input())
lst=[]
for i in range(num):
    lst.append(int(input()))

for i in range(num):
    flag = 1
    for j in range(2, int(math.sqrt(lst[i])) + 1):
        if lst[i] % j == 0:
            flag = 0
    if lst[i] <= 1:
        flag = 0
    if flag==1:
        print("Yes")
    else:
        print("No")

 

posted @ 2024-06-29 16:27  豆豆是只乖狗狗  阅读(4)  评论(0编辑  收藏  举报