Sieve of Eratosthenes

class SieveOfEratosthenes
#include <sieve-of-eratosthenes.hpp>

Computes the prime numbers lower than an integer n.

Public Functions

SieveOfEratosthenes(const int n)
inline bool isPrime(const int k) const

Returns if k is prime.

inline int primeCount() const

Returns the number of prime numbers lower than n.

inline int nthPrime(const int k) const

Returns the k-th prime number.

inline const std::vector<int> &primes() const

Returns a vector containing all the prime numbers lower than n, in ascending order.

Private Members

std::vector<bool> m_isPrime
std::vector<int> m_primes