User Rating 0.0 β˜…β˜…β˜…β˜…β˜…
Total Usage 0 times
Supports integers of any size (BigInt)
Examples:
Range Scanner
Is this tool helpful?

Your feedback helps us improve.

β˜… β˜… β˜… β˜… β˜…

About

A miscounted prime breaks RSA key generation. A wrong factorization invalidates a cryptographic proof. This tool applies the deterministic Miller-Rabin primality test with witness set [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] to produce a guaranteed correct result for any integer n < 3.317 Γ— 1024. For composite inputs, the tool returns the complete prime factorization via trial division combined with Pollard's Rho algorithm. Results are deterministic, not probabilistic. The tool handles arbitrarily large integers through JavaScript BigInt arithmetic.

Limitation: for integers exceeding 1018, factorization of large composite numbers may take several seconds if the number has two very large prime factors. The primality verdict itself remains instant regardless of size. Pro tip: when verifying Mersenne primes of the form 2p βˆ’ 1, first confirm that p itself is prime.

prime number checker primality test miller-rabin prime factorization math tool number theory

Formulas

The Miller-Rabin test expresses n βˆ’ 1 as 2s β‹… d where d is odd, then checks witnesses:

n βˆ’ 1 = 2s β‹… d

For each witness a, compute:

x = ad mod n

If x = 1 or x = n βˆ’ 1, the number passes for this witness. Otherwise, square x up to s βˆ’ 1 times:

x ← x2 mod n

If x never reaches n βˆ’ 1, then n is composite. The Prime Number Theorem gives the approximate count of primes below n:

Ο€(n) nln(n)

Where Ο€(n) is the prime-counting function and ln is the natural logarithm. For factorization of composite numbers, Pollard's Rho uses the iteration x ← x2 + c mod n with Floyd's cycle detection to find gcd(|x βˆ’ y|, n) > 1.

Reference Data

RangeCount of PrimesPrime DensityLargest Prime in Range
1 - 10440.0%7
1 - 1002525.0%97
1 - 1,00016816.8%997
1 - 10,0001,22912.29%9,973
1 - 100,0009,5929.59%99,991
1 - 1,000,00078,4987.85%999,983
1 - 10,000,000664,5796.65%9,999,991
1 - 1085,761,4555.76%99,999,989
1 - 10950,847,5345.08%999,999,937
1 - 1010455,052,5114.55%9,999,999,967
Notable Primes
Largest known twin prime2,996,863,034,895 Γ— 21,290,000 Β± 1 (388,342 digits)
Largest known Mersenne prime2136,279,841 βˆ’ 1 (41,024,320 digits, M52)
First 20 primes2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71
Mersenne exponents2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607
Fermat primes (known)3, 5, 17, 257, 65537

Frequently Asked Questions

The probabilistic Miller-Rabin test uses random witnesses and has a false-positive rate of at most 1/4 per witness. The deterministic variant uses a fixed, proven set of witnesses. For n < 3.317 Γ— 1024, the witness set {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37} produces zero false positives. The result is guaranteed correct, not probable.
The Fundamental Theorem of Arithmetic states every integer greater than 1 has a unique prime factorization. If 1 were prime, uniqueness would break: 6 = 2 Γ— 3 = 1 Γ— 2 Γ— 3 = 12 Γ— 2 Γ— 3. Excluding 1 preserves this theorem.
Primality testing runs in polynomial time. Miller-Rabin with k witnesses performs O(k β‹… log2n) modular multiplications. Integer factorization has no known polynomial-time algorithm on classical computers. Trial division is O(√n). Pollard's Rho achieves expected O(n1/4) for finding a factor.
Yes. The tool uses JavaScript BigInt for arbitrary-precision arithmetic. The primality test completes in milliseconds for numbers up to several hundred digits. Factorization of composite numbers with large prime factors may take longer. If both prime factors exceed 109, the Pollard's Rho step could take seconds to minutes depending on factor size.
The Prime Number Theorem states Ο€(n) β‰ˆ n Γ· ln(n). At n = 106, roughly 7.85% of integers are prime. At n = 109, it drops to 5.08%. The gap between consecutive primes grows logarithmically on average, but arbitrarily large gaps exist (proven by the Green-Tao theorem context and prime gap results).
2 is correctly identified as the smallest and only even prime. 0 and 1 return "not prime" with an explanation. Negative numbers and non-integer inputs are rejected with a validation error. The tool only accepts positive integers β‰₯ 0.