Skip to main content

Crate use_prime

Crate use_prime 

Source
Expand description

§use-prime

Small prime number utilities for RustUse.
Practical primality checks, prime generation, sieves, and deterministic factorization without cryptographic or arbitrary-precision concerns.

Rust 1.95.0+ Edition 2024 Prime utilities License MIT or Apache-2.0

§Install

[dependencies]
use-prime = "0.0.5"

§What belongs here

use-prime owns practical prime-number utilities: primality checks, next and previous prime search, sieve generation, and deterministic prime factorization over primitive unsigned integers.

This crate is intended for practical number-theory helpers, not cryptographic prime generation. It keeps the first release explicit, dependency-free, and predictable.

§Neighboring crates

CrateResponsibility
use-primePrimality checks, prime search, sieves, and factorization
use-modularModular arithmetic, congruence, inverses, and exponentiation
use-arithmeticGCD, LCM, divisibility, parity, and arithmetic helpers
use-integerInteger classification and integer-specific descriptive helpers
use-numberBroader number abstractions and shared numeric vocabulary
use-combinatoricsCounting helpers that may consume prime utilities
use-algebraAlgebraic structures and law checking over caller-supplied ops
use-cryptographyFuture cryptographic protocols and stronger prime requirements

use-prime intentionally does not define modular arithmetic, probabilistic primality tests, cryptographic-strength prime generation, or arbitrary-precision integer support.

§Examples

§Primality and neighboring primes

use use_prime::{is_prime, next_prime, previous_prime};

assert!(is_prime(13));
assert_eq!(next_prime(13), Some(17));
assert_eq!(previous_prime(13), Some(11));

§Prime factors and multiplicities

use use_prime::{factorization, prime_factors, unique_prime_factors};

assert_eq!(prime_factors(60), vec![2, 2, 3, 5]);
assert_eq!(unique_prime_factors(60), vec![2, 3, 5]);
assert_eq!(factorization(60), vec![(2, 2), (3, 1), (5, 1)]);

§Sieve-backed prime generation

use use_prime::primes_up_to;

assert_eq!(primes_up_to(20), vec![2, 3, 5, 7, 11, 13, 17, 19]);

§Status

use-prime is a concrete pre-1.0 crate in the RustUse math workspace. The API stays small and deterministic so adjacent number, integer, arithmetic, modular, combinatorics, algebra, and future cryptography crates can share one focused prime-utility surface. Small prime number utilities for RustUse.

Re-exports§

pub use factorization::factorization;
pub use factorization::prime_factors;
pub use factorization::unique_prime_factors;
pub use primality::is_composite;
pub use primality::is_prime;
pub use primality::next_prime;
pub use primality::previous_prime;
pub use sieve::primes_up_to;
pub use sieve::sieve;

Modules§

factorization
Prime factorization helpers.
primality
Primality checks and neighboring prime search.
sieve
Prime sieves and sieve-backed prime generation.