Project Euler Solutions
Classes | Typedefs | Functions | Variables
c::include::primes Namespace Reference

Classes

struct  prime_counter
 A cached prime number generator. More...
 
struct  prime_factor_counter
 
struct  prime_sieve
 

Typedefs

typedef struct prime_sieve prime_sieve
 
typedef struct prime_counter prime_counter
 
typedef struct prime_factor_counter prime_factor_counter
 

Functions

prime_sieve prime_sieve0 ()
 
void free_prime_counter (prime_counter *pc)
 
prime_counter prime_counter1 (uintmax_t stop)
 
prime_counter prime_counter0 ()
 
void free_prime_factor_counter (prime_factor_counter *pfc)
 
uintmax_t is_composite (uintmax_t n)
 Tells you if a number is composite, and if so, its smallest prime factor. More...
 
bool is_prime (uintmax_t n)
 Tells you if a number is prime. More...
 

Variables

static uintmax_t * prime_cache = NULL
 
static uintmax_t prime_cache_max = 0
 
static size_t prime_cache_size = 0
 
static size_t prime_cache_idx = 0
 

Typedef Documentation

Function Documentation

void c::include::primes::free_prime_counter ( prime_counter pc)
void c::include::primes::free_prime_factor_counter ( prime_factor_counter pfc)
inline

Here is the caller graph for this function:

uintmax_t is_composite ( uintmax_t  n)

Tells you if a number is composite, and if so, its smallest prime factor.

Parameters
nThe number you wish to test
Returns
Either 0 or the number's smallest prime factor

Here is the call graph for this function:

Here is the caller graph for this function:

bool c::include::primes::is_prime ( uintmax_t  n)
inline

Tells you if a number is prime.

Parameters
nThe number you wish to test
Returns
A bool indicating whether a number is prime

Here is the call graph for this function:

Here is the caller graph for this function:

prime_counter c::include::primes::prime_counter0 ( )
inline

Here is the call graph for this function:

prime_counter c::include::primes::prime_counter1 ( uintmax_t  stop)
inline

Here is the call graph for this function:

Here is the caller graph for this function:

prime_sieve c::include::primes::prime_sieve0 ( )

Here is the caller graph for this function:

Variable Documentation

uintmax_t* c::include::primes::prime_cache = NULL
static
size_t c::include::primes::prime_cache_idx = 0
static
uintmax_t c::include::primes::prime_cache_max = 0
static
size_t c::include::primes::prime_cache_size = 0
static