Prime number checker
Test primality with deterministic Miller-Rabin (exact for 64-bit integers) plus factorization, smallest prime factor, neighbouring primes, the n-th prime, primes in a range and π(n) estimates.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Prime
Primality is decided with deterministic Miller-Rabin (first 12 primes as bases); results are guaranteed correct for 64-bit integers
Sieve of Eratosthenes with a 1,000,000-length and 1e9 upper bound
101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199
What this tool does
- Test whether a large integer is prime: within 64-bit range the deterministic Miller-Rabin run gives a guaranteed answer, not a probabilistic guess.
- Factor large integers when sizing RSA moduli, hash moduli or random-number schemes — Pollard rho handles 64-bit semiprimes.
- Look up neighbouring primes, the n-th prime (n up to 100,000) or every prime in a range, handy for checking algorithm homework.
- Estimate π(n) with n / (ln n − 1), or get the exact prime count when n is at most ten million.
Example
Input
1000000016000000063
Output
Composite = 1000000007 × 1000000009
This is the product of two adjacent ten-digit primes; trial division plus Pollard rho yields the ascending factor list, with a factorization ceiling of 2^64 − 1.
Frequently asked questions
Can the primality test be wrong?
No. The Miller-Rabin bases are the first twelve primes, a set that is deterministic for values below 3.3×10^24, which covers every 64-bit integer. Above that bound the tool refuses rather than answering "probably prime".
Why does it refuse input above 18446744073709551615?
The whole module is designed around unsigned 64-bit integers: factorization stops at 2^64 − 1, the range sieve stops at an upper bound of 1e9, and exact π(n) stops at ten million. Going beyond reports an out-of-range error instead of hanging the page.
How are 0, 1 and negative numbers handled?
Zero and one are neither prime nor composite, and the test says exactly that. Factorization and smallest-prime-factor require at least 1, so negative input is rejected with a "non-negative integer" message.
Can I paste numbers with separators?
Yes. Underscores, spaces and thousands separators are stripped before parsing, so 1_000_000_007 and 1,000,000,007 both work; anything that is not a plain integer after stripping is rejected.
Why is the range length limited?
The range uses a segmented sieve that allocates a flag array for the whole span. Capping the length at one million and the upper bound at 1e9 keeps results coming back within a second or two.
Keywords:prime质数素数prime checkmiller-rabinfactorization因数分解nth primesieve埃氏筛pi(n)