gateway/test-chat/extraction/method_ai_20251004-110620/raw_result.txt
2025-10-04 13:31:21 +02:00

12 lines
No EOL
1.4 KiB
Text

```json
{
"documents": [
{
"data": "def sieve_of_eratosthenes(limit):\n primes = []\n is_prime = [True] * (limit + 1)\n for num in range(2, limit + 1):\n if is_prime[num]:\n primes.append(num)\n for multiple in range(num * num, limit + 1, num):\n is_prime[multiple] = False\n return primes\n\n\ndef is_prime_trial_division(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i += 6\n return True\n\n\n# Calculate the first 1000 prime numbers\nlimit = 7920 # A rough estimate to ensure we get at least 1000 primes\nprimes = sieve_of_eratosthenes(limit)\nfirst_1000_primes = primes[:1000]\n\n# Validate the list of primes\nvalidated_primes = [p for p in first_1000_primes if is_prime_trial_division(p)]\n\n# Check if the validation was successful\nassert len(validated_primes) == 1000, \"Validation failed: Not all numbers are prime\"\n\nprint(\"First 1000 primes calculated and validated successfully.\")",
"mimeType": "text/plain",
"comment": "This script calculates the first 1000 prime numbers using the Sieve of Eratosthenes and validates them using trial division."
}
],
"continue": false
}
```