Team AllStuWrite's repo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
502 B

from math import sqrt
def isPrime(n):
m=int(sqrt(n))
for i in range(2,m+1):
if n%i ==0:
return False
return True
def countPrimes(start,end):
cnt=0
for i in range(start,end+1):
if(isPrime(i)):
cnt+=1;
return cnt
#主程序
for start in range(1,1000,100):
print("%3d-%4d%d个素数"%\
(start,start+99,countPrimes(start,start+99)))