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)