primesieve  11.0
primes_vector.cpp

Fill a std::vector with primes.

#include <primesieve.hpp>
#include <vector>
int main()
{
std::vector<int> primes;
// Fill the primes vector with the primes <= 1000
primes.clear();
// Fill the primes vector with the primes inside [1000, 2000]
primesieve::generate_primes(1000, 2000, &primes);
primes.clear();
// Fill the primes vector with the first 1000 primes
primes.clear();
// Fill the primes vector with the first 10 primes >= 1000
primesieve::generate_n_primes(10, 1000, &primes);
return 0;
}
primesieve C++ API.
void generate_primes(uint64_t stop, vect *primes)
Appends the primes <= stop to the end of the primes vector.
Definition: primesieve.hpp:34
void generate_n_primes(uint64_t n, vect *primes)
Appends the first n primes to the end of the primes vector.
Definition: primesieve.hpp:56