10 std::mt19937 gen(rd());
11 int max_number = 50000;
13 auto start = std::chrono::high_resolution_clock::now();
15 std::vector<int> primes =
18 auto end = std::chrono::high_resolution_clock::now();
19 std::chrono::duration<double> duration = end - start;
21 std::cout <<
"Prime numbers generated: " << primes.size() << std::endl;
22 std::cout <<
"Time taken: " << duration.count() <<
" seconds" << std::endl;
25 if (!primes.empty()) {
26 std::uniform_int_distribution<> distrib(0, primes.size() - 1);
27 int random_index = distrib(gen);
28 std::cout <<
"Random prime number: " << primes[random_index]
31 std::cout <<
"No prime numbers generated." << std::endl;
static std::vector< int > sieve_of_eratosthenes(int n)