SDDSlib
|
Routines for prime factorization and primality testing. More...
#include "mdb.h"
Go to the source code of this file.
Functions | |
int64_t | is_prime (int64_t number) |
Determine if a number is prime. | |
int64_t | smallest_factor (int64_t number) |
Find the smallest prime factor of a number. | |
int64_t | next_prime_factor (int64_t *number) |
Extract the next prime factor from a number. | |
int64_t | largest_prime_factor (int64_t number) |
Find the largest prime factor of a number. | |
Routines for prime factorization and primality testing.
Definition in file factorize.c.
int64_t is_prime | ( | int64_t | number | ) |
Determine if a number is prime.
Checks if the given number is prime.
number | The number to test. |
Definition at line 26 of file factorize.c.
int64_t largest_prime_factor | ( | int64_t | number | ) |
Find the largest prime factor of a number.
Iteratively factorizes the given number to determine its largest prime factor.
number | The number to factorize. |
Definition at line 83 of file factorize.c.
int64_t next_prime_factor | ( | int64_t * | number | ) |
Extract the next prime factor from a number.
Removes and returns the next prime factor from the given number, dividing it out of the number. Subsequent calls will continue to factorize the updated number.
number | Pointer to the number to factorize. On return, this value is reduced by dividing out the factor. |
Definition at line 65 of file factorize.c.
int64_t smallest_factor | ( | int64_t | number | ) |
Find the smallest prime factor of a number.
Returns the smallest prime factor of a given number. If the number is prime, returns the number itself.
number | The number for which to find the smallest factor. |
Definition at line 46 of file factorize.c.