输出1000以内素数的和:
sum=0 m=0 for n in range(2,1001): if n%2==0: continue for i in range(3,int(n**0.5)+1,2): if n%i==0: break else: sum+=n m=m+1 if m<=19: print(n,end=",") else: print(n) m=0 print("素数总和为:",+sum) `
欢迎分享,转载请注明来源:内存溢出
输出1000以内素数的和:
sum=0 m=0 for n in range(2,1001): if n%2==0: continue for i in range(3,int(n**0.5)+1,2): if n%i==0: break else: sum+=n m=m+1 if m<=19: print(n,end=",") else: print(n) m=0 print("素数总和为:",+sum) `
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)