题解 | 素数判断

素数判断

https://www.nowcoder.com/practice/5ab1b9690af047699e96c87dee65def4

T=int(input())

def is_prime(n) :
    if n<2:
        return "No"
    if n==2:
        return "Yes"
    if n%2==0:
        return "No"
    
    for i in range(3,n,2):
        if n%i==0 :
            return "No"
    return "Yes"

for j in range(T) :
    num=int(input())
    print(is_prime(num))

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务