12 lines
No EOL
992 B
Text
12 lines
No EOL
992 B
Text
```json
|
|
{
|
|
"documents": [
|
|
{
|
|
"data": "def sieve_of_eratosthenes(n):\n \"\"\"\n Calculate the first n prime numbers using the Sieve of Eratosthenes algorithm.\n \"\"\"\n limit = 10000 # Start with an arbitrary limit\n primes = []\n while len(primes) < n:\n limit *= 2 # Double the limit if not enough primes are found\n is_prime = [True] * (limit + 1)\n p = 2\n while (p * p <= limit):\n if (is_prime[p] == True):\n for i in range(p * p, limit + 1, p):\n is_prime[i] = False\n p += 1\n primes = [p for p in range(2, limit) if is_prime[p]]\n return primes[:n]\n\n# Calculate the first 1000 prime numbers\nfirst_1000_primes = sieve_of_eratosthenes(1000)\nprint(first_1000_primes)\n",
|
|
"mimeType": "text/plain",
|
|
"comment": "This Python code calculates the first 1000 prime numbers using the Sieve of Eratosthenes algorithm."
|
|
}
|
|
],
|
|
"continue": false
|
|
}
|
|
``` |