Factorial Engine
A high-performance, zero-error Rust crate for computing the prime factorization of factorials (n!).
This engine is designed as a robust, backend computational tool. It uses Legendre's Formula to calculate prime exponents directly, completely avoiding the need to compute or store the immense values of n! itself. This ensures exceptional performance and prevents any possibility of integer overflow, even for very large n.
Features
- High Performance: Employs Legendre's Formula for direct calculation of prime exponents.
- Zero Error: Avoids large number arithmetic entirely, making it robust and free from overflow errors.
- Efficient Prime Generation: Includes an optimized Sieve of Eratosthenes for on-demand prime generation and caching.
- Symbolic Factorials: [
SymbolicFactorial] representsn!as a displayable prime factorization (e.g.2^47 × 3^22 × 5^12 × ...). - Symbolic Arithmetic:
multiply,checked_divide, andpowcombine symbolic factorials (e.g. for binomial coefficients) without ever computing the underlying integers. - BigUint Support:
to_biguint,FactorialEngine::factorial_biguint, andFactorialEngine::binomialmaterialize exact, arbitrary-precision results vianum-bigintonly when you actually need the number. - Reverse Factorial: [
reverse_factorial] recoversnfrom a candidate factorial value, e.g.reverse_factorial(120) == Ok(5). - Clean API: Provides a simple and clear interface for getting the full symbolic factorization of
n!.
Usage
Add this crate to your Cargo.toml:
[]
= "0.3.0" # Or the latest version
Example
use ;
Purpose
This crate serves as a foundational block for applications in number theory, combinatorics, and computational mathematics. It is designed to be a reliable, "black-box" dependency that provides factorial factorization data with maximum efficiency and correctness.
Author
Neil Crago
Related Crates
This crate is part of a collection of crates by the same author: These include:-
- MOMA
- MOMA_simulation_engine
- Fractal_Algebra
- tma_engine
- fa_slow_ai