Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Prime Numbers

Synopsis
#include <boost/math/special_functions/prime.hpp>
namespace boost { namespace math {

template <class Policy>
boost::uint32_t prime(unsigned n, const Policy& pol);

boost::uint32_t prime(unsigned n);

static const unsigned max_prime = 10000;

}} // namespaces
Description

The function prime provides fast table lookup to the first 10000 prime numbers (starting from 2 as the zeroth prime: as 1 isn't terribly useful in practice). There are two function signatures one of which takes an optional Policy as the second parameter to control error handling.

The constant max_prime is the largest value you can pass to prime without incurring an error.

Passing a value greater than max_prime results in a domain_error being raised.


PrevUpHomeNext