mirror of
https://github.com/boostorg/math.git
synced 2026-01-24 18:12:09 +00:00
prime approximation function for a range
This commit is contained in:
@@ -235,12 +235,18 @@ void sequential_segmented_sieve(Integer lower_bound, Integer upper_bound, Contai
|
||||
} // End namespace detail
|
||||
|
||||
template<class Integer>
|
||||
constexpr Integer prime_approximation(Integer upper_bound)
|
||||
constexpr Integer prime_approximation(const Integer upper_bound)
|
||||
{
|
||||
constexpr auto c = 30 * std::log(113) / 113; // Magic numbers from wikipedia
|
||||
return static_cast<Integer>(std::floor(c * upper_bound / std::log(static_cast<double>(upper_bound))));
|
||||
}
|
||||
|
||||
template<class Integer>
|
||||
constexpr Integer prime_approximation(const Integer lower_bound, const Integer upper_bound)
|
||||
{
|
||||
return prime_approximation(upper_bound) - prime_approximation(lower_bound);
|
||||
}
|
||||
|
||||
template<class Integer>
|
||||
constexpr void prime_reserve(Integer upper_bound, std::vector<Integer> &prime_container)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user