E.V.E
v2023.02.15
Loading...
Searching...
No Matches
◆
nth_prime
eve::nth_prime = functor<nth_prime_t>
inline
constexpr
Header file
#include <eve/module/combinatorial.hpp>
Callable Signatures
namespace
eve
{
constexpr
auto
nth_prime
(
unsigned_value
auto
x
) ->
decltype
(
x
)
noexcept
;
//1
template
<
int
egral_value T,
float
ing_scalar_value U>
constexpr
as_wide_as_t<U, T>
nth_prime
(
T
x
,
as<U>
)
noexcept
;
//2
template
<
int
egral_value T,
unsigned
_scalar_value U>
constexpr
as_wide_as_t<U, T>
nth_prime
(
T
x
,
as<U>
)
noexcept
;
//2
}
eve::unsigned_value
The concept unsigned_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition
value.hpp:84
eve::nth_prime
constexpr auto nth_prime
Returns the nth prime number.
Definition
nth_prime.hpp:86
eve::translate_t
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition
translation.hpp:107
eve
EVE Main Namespace.
Definition
abi.hpp:19
Parameters
n
: unsigned argument. If n is greater than 10'000, behavior is undefined.
Return value
The nth prime is returned.
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
Wikipedia: Prime number
Example
#include <eve/eve.hpp>
#include <eve/module/combinatorial.hpp>
#include <iostream>
int
main
() {
eve::wide<std::uint32_t>
wu
([](
auto
i,
auto
)->std::uint32_t{
return
i;});
eve::wide
n
{52u, 53u, 6541u, 6542u, 0
u
, 1u, 999u, 10000u};
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"
;
}
eve::wide
Wrapper for SIMD registers.
Definition
wide.hpp:94
eve