-
Notifications
You must be signed in to change notification settings - Fork 0
Algorithm overview
Ahmet Burak Biçer edited this page Jun 30, 2026
·
1 revision
Exact trial division up to
- Handle
$n < 2$ ,$2$ ,$3$ , other evens. - Reject multiples of
$3,5,7,11,13$ (baked into wheel modulus$30030$ ). -
$\lfloor\sqrt{n}\rfloor$ via hardwaresqrt+ integer correction. - Walk candidates coprime to
$30030 = 2\cdot3\cdot5\cdot7\cdot11\cdot13$ using hardcoded wheelW30030(5760 steps), starting at$17$ . - Optional multi-threading: split the candidate range with Numba
prange(same idea as OpenMP chunks).
If no divisor appears by
- Trial division by small primes and odds up to a practical bound (or
$\sqrt{n}$ ). - If the bound reaches
$\sqrt{n}$ , answer is exact. - Otherwise AKS — unconditional and deterministic, but potentially very slow for large primes with no small factors.
- Benchmarks — primitive vs optimized
- Source:
is_prime.py
Best-Prime-Number-Function — deterministic primality (no stochastic MR) · Source · Wiki maintained from docs/wiki/ + this GitHub Wiki
Wiki
- Home
- Project restrictions
- Algorithm overview
- CI and automation
- Agent briefing
- Contributing
- Benchmarks
- Hall of fame
AI-designed project — review before production use.