MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / isPrimeBigint

Function isPrimeBigint

src/compute-engine/numerics/primes.ts:171–182  ·  view source on GitHub ↗
(n: bigint)

Source from the content-addressed store, hash-verified

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.
175const 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).
180const MILLER_RABIN_BASES = [
181 2n,
182 3n,
183 5n,
184 7n,
185 11n,

Callers 4

number-theory.tsFile · 0.90
isPrimeFunction · 0.90
isPrimeFunction · 0.85
factorWithRhoFunction · 0.85

Calls 2

millerRabinFunction · 0.85
hasMethod · 0.65

Tested by

no test coverage detected