| 1 |
# num-prime |
| 2 |
|
| 3 |
[](https://crates.io/crates/num-prime) |
| 4 |
[](https://codspeed.io/uutils/num-prime?utm_source=badge) |
| 5 |
[](https://discord.gg/wQVJbvJ) |
| 6 |
[](https://github.com/uutils/num-prime/blob/main/LICENSE) |
| 7 |
[](https://deps.rs/repo/github/uutils/num-prime) |
| 8 |
|
| 9 |
[](https://codecov.io/gh/uutils/num-prime) |
| 10 |
|
| 11 |
This crate provides utilities for prime number related functionalities: |
| 12 |
|
| 13 |
- Primality testing |
| 14 |
- Deterministic primality check of `u64` integers (using a very fast hashing algorithm) |
| 15 |
- Fermat probable prime test |
| 16 |
- Miller-rabin probable prime test |
| 17 |
- (strong/extra strong) Lucas probable prime test |
| 18 |
- Baillie-PSW test |
| 19 |
- Sophie Germain safe prime test |
| 20 |
- Primes generation and indexing |
| 21 |
- A naive implementation of the sieve of Eratosthenes |
| 22 |
- Unified API to support other prime generation backends |
| 23 |
- Generate random (safe) primes |
| 24 |
- Find previous/next prime |
| 25 |
- Integer factorization |
| 26 |
- Trial division |
| 27 |
- Pollard's rho algorithm |
| 28 |
- Shanks's square forms factorization (SQUFOF) |
| 29 |
- Fast factorization of `u64` and `u128` integers |
| 30 |
- Number theoretic functions |
| 31 |
- Prime Pi function (number of primes under limit), its estimation and its bounds |
| 32 |
- Nth prime, its estimation and its bounds |
| 33 |
- Moebius function |
| 34 |
- Divisor Sigma function *([in examples](./examples/divisor_sigma.rs))* |
| 35 |
- Prime Omega function *([in examples](./examples/prime_omega.rs))* |
| 36 |
|
| 37 |
It's based on the `num` creates and most functions are decently optimized with pre-computed tables (see **[benchmark results here](./PERFORMANCE.md)**). |