#include <cmath>
#include <random>
#include <vector>
Go to the source code of this file.
- Author
- Khrapov
- Date
- 6.08.2022
- Copyright
- © Nick Khrapov, 2022. All right reserved.
Definition in file prime.h.
◆ find_prime_factors()
template<class I >
std::vector<I> qx::find_prime_factors |
( |
I |
nValue | ) |
|
|
inline |
Find all prime factors.
- Complexity:
- O(sqrt(number))
- Template Parameters
-
- Parameters
-
nValue | - number for search |
- Return values
-
- | all prime factors vector |
Definition at line 26 of file prime.h.
◆ find_primes()
template<class I >
std::vector<I> qx::find_primes |
( |
I |
nMaxNumber | ) |
|
|
inline |
Find all primes between 2 and nMaxNumber.
Sieve of Eratosthenes
- Complexity:
- O(nMaxNumber * log(log(number)))
- Template Parameters
-
- Parameters
-
nMaxNumber | - max number for search |
- Return values
-
Definition at line 84 of file prime.h.
◆ is_prime() [1/2]
bool qx::is_prime |
( |
size_t |
nValue | ) |
|
|
inline |
Is number prime.
1.0 probability, high computational complexity
- Complexity:
- O(sqrt(number))
- Parameters
-
- Return values
-
Definition at line 129 of file prime.h.
◆ is_prime() [2/2]
bool qx::is_prime |
( |
size_t |
nValue, |
|
|
double |
fProbability |
|
) |
| |
|
inline |
Is number prime with some probability.
- Parameters
-
nValue | - number |
fProbability | - probability (0, 1] |
- Return values
-
- | true is number is prime with some probability |
Definition at line 140 of file prime.h.