(n: bigint)
| 169 | if (!Number.isInteger(n) || !Number.isFinite(n) || n <= 1) return false; |
| 170 | return isPrimeBigint(BigInt(n)); |
| 171 | } |
| 172 | |
| 173 | // Above this bound, primality is decided by Miller–Rabin rather than trial |
| 174 | // division. |
| 175 | const MILLER_RABIN_THRESHOLD = 1n << 32n; |
| 176 | |
| 177 | // The first 12 primes are a deterministic Miller–Rabin witness set for every |
| 178 | // n < 3.3·10²⁴, so `isPrimeBigint` is exact across that range (and an |
| 179 | // extremely reliable probable-prime test beyond it). |
| 180 | const MILLER_RABIN_BASES = [ |
| 181 | 2n, |
| 182 | 3n, |
| 183 | 5n, |
| 184 | 7n, |
| 185 | 11n, |
no test coverage detected