gateway/test-chat/extraction/method_ai_20251004-142510/ai_result_r0t0a0.txt
2025-10-04 18:44:42 +02:00

25 lines
No EOL
729 B
Text

def sieve_of_eratosthenes(limit):
primes = []
is_prime = [True] * (limit + 1)
p = 2
while p * p <= limit:
if is_prime[p]:
for i in range(p * p, limit + 1, p):
is_prime[i] = False
p += 1
for p in range(2, limit + 1):
if is_prime[p]:
primes.append(p)
return primes
# Estimate an upper bound for the 1000th prime number
# Using the approximation n * log(n) + n * log(log(n)) for the nth prime
import math
n = 1000
upper_bound = int(n * math.log(n) + n * math.log(math.log(n)))
# Calculate the first 1000 prime numbers
first_1000_primes = sieve_of_eratosthenes(upper_bound)[:1000]
# Print the first 1000 prime numbers
print(first_1000_primes)