我這樣子寫被killed
def isPrime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return Truewhile True:
try:
a,b=map(int,input().split())
if b-a>1000:
print(0)
break
# 計算範圍內的質數數量
prime_count = 0
for num in range(a, b + 1):
if isPrime(num):
prime_count += 1
# 輸出質數數量
print(prime_count)
except EOFError:
break