Miller-Rabin
Deterministic below 2⁶⁴. Identifies primes before any factoring work begins.
A single Python API for the entire factorisation stack — Miller-Rabin, Pollard's Rho, ECM, Quadratic Sieve, SIQS, GNFS — automatically composed into an adaptive pipeline.
Python 3.10+ · MIT licensed · Used in crypto, math-ed & CTF tooling
1 from factorise import factorise, is_prime
2
3 › factorise(123456789)4 3² · 3607 · 3803factorise escalates from fast, cheap methods to heavyweight sieves, stopping the moment a factor is found. You don't pick — it does.
Deterministic below 2⁶⁴. Identifies primes before any factoring work begins.
Strips tiny prime factors first. Bound is configurable; defaults to 10,000.
Efficient when p-1 is B-smooth. Bound configurable up to millions.
Cycle-detection with Brent's improvement. The workhorse of mid-size integers.
Elliptic curves. Tunable curve count. The bridge between Pollard's and sieves.
Classical sieve. Reliable up to ~70 digits with a tuned relation budget.
Knuth-Schroeppel optimised sieve. Faster than QS in practice on typical inputs.
Sub-exponential. Adapter shells out to `msieve` for the heaviest workloads.
Every result is reproducible. No random walks, no probabilistic answers — just correct factorisation every call.
Pure Python and the standard library. Drop it into any environment without supply-chain risk.
The hybrid router picks the right algorithm for every input size automatically.
PEP 484 hints across the public API. Plays nicely with mypy, pyright, and your IDE.
97% coverage with Hypothesis property tests, regression sweeps, and CI-enforced benchmarks.
A router inspects your input and dispatches to the optimal stage. Configure thresholds, or just let it pick.
Read the docsA single, consistent API. Functional when you want it concise, a pipeline when you want control. No surprises.
Get .factors, .powers and a printable .expression().
factorise 123456789 --verbose for ops and debugging.
Optional seeding makes Pollard-Brent retries byte-identical.
from factorise import factorise
result = factorise(123456789)
print(result.expression())
# '3^2 * 3607 * 3803' from factorise import FactorisationPipeline, PipelineConfig
pipeline = FactorisationPipeline(
PipelineConfig(trial_division_bound=10_000,
pm1_bound=10**6,
ecm_curves=50)
)
result = pipeline.attempt(10**18 + 9) from factorise import (
HybridFactorisationEngine, HybridConfig,
)
engine = HybridFactorisationEngine(HybridConfig())
# Routes automatically by input size
result = engine.attempt(n) factorise runs on any modern Python. No compilers, no system libraries, no surprises.
pip install factorise factorise 123456789 --verbose python -c "from factorise import factorise; print(factorise(10**18+9).expression())" Open-source, MIT-licensed, and built for the engineers who can't afford to be wrong.