E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ nth_prime

auto eve::nth_prime = functor<nth_prime_t>
inlineconstexpr

Header file

#include <eve/module/combinatorial.hpp>

Callable Signatures

namespace eve
{
constexpr auto nth_prime(unsigned_value auto x) -> decltype(x) noexcept; //1
template < integral_value T, floating_scalar_value U>
constexpr as_wide_as_t<U, T> nth_prime(T x, as<U>) noexcept; //2
template < integral_value T, unsigned_scalar_value U>
constexpr as_wide_as_t<U, T> nth_prime(T x, as<U>) noexcept; //2
}
The concept unsigned_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:84
constexpr auto nth_prime
Returns the nth prime number.
Definition nth_prime.hpp:86
EVE Main Namespace.
Definition abi.hpp:18
Lightweight type-wrapper.
Definition as.hpp:29

Parameters

  • n : unsigned argument. If n is greater than 10'000, behavior is undefined.

Return value

  1. The nth prime is returned.
  2. Same, but the element type of the result is deduced from U.

Notes

  • 2 is the first prime. It is returned for n=0.
  • Almost no computations are made, the results are from a lookup table.

External references

Example

// revision 1
#include <eve/module/combinatorial.hpp>
#include <iostream>
eve::wide<std::uint32_t> wu([](auto i, auto )->std::uint32_t{ return i;});
eve::wide n{52u, 53u, 6541u, 6542u, 0u, 1u, 999u, 10000u};
int main(){
std::cout << "<- wu = " << wu << "\n";
std::cout << "<- n = " << n << "\n";
std::cout << "-> nth_prime(wu)= " << eve::nth_prime(wu) << "\n";
std::cout << "-> nth_prime(n) = " << eve::nth_prime(n) << "\n";
}
Wrapper for SIMD registers.
Definition wide.hpp:86