打印1000以内的质数

1+

<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class=”mce_SELRES_start”>

def isprime(x):

    if x<2:
        flag=False
    else:
        flag = True

    for i in range(2,x):
        if x % i ==0 :
            flag = False
            break
        
    return flag

for z in range(1000):
    if isprime(z):
        print(z,end=' ')



1+

发表评论