Math · Number theory
Is it prime? Checker.
Test whether a number is prime, up to 10^24. Composite numbers show their factorization, and every result shows the nearest primes either side.
Inputs
Result
Enter a whole number.
How to tell if a number is prime
A prime is a whole number above 1 with no divisors except 1 and itself (OEIS A000040). The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. Zero and 1 are not prime, and 2 is the only even prime.
By hand. Test divisibility by primes up to the square root of the number: if none divides it, it is prime. 97 is prime because 2, 3, 5 and 7 do not divide it and 11 squared is already above 97.
For big numbers. This tool uses the Miller-Rabin test with the first 13 prime bases (2 to 41). The smallest odd composite that passes all 13 is 3,317,044,064,679,887,385,961,981 (Sorenson and Webster, OEIS A014233), so for input below 10^24 a pass is a proof of primality. Worked examples. 561 = 3 x 11 x 17 is composite even though it fools the simple Fermat test. 2^61 - 1 = 2,305,843,009,213,693,951 is prime.
Frequently asked questions
Is 1 a prime number?
No. A prime needs exactly two divisors; 1 has only one. 0 is not prime either.
Is 2 the only even prime?
Yes. Every other even number is divisible by 2 and is therefore composite.
How do you check if a large number is prime?
Use a probabilistic test such as Miller-Rabin. With the first 13 prime bases it is deterministic for every number below 3.3 x 10^24, which covers this tool's whole range.
Is 561 prime?
No. 561 = 3 x 11 x 17. It is the smallest Carmichael number (OEIS A002997), a composite that fools the plain Fermat test but not Miller-Rabin.
What is the next prime after a number?
This tool tests each following number in turn. The next prime after 100 is 101 and the previous one is 97.
Sources
Checked
- OEIS A000040: The prime numbers
- OEIS A014233 (Sorenson and Webster, arXiv:1509.00864)
- OEIS A002997: Carmichael numbers
The 561 example is from OEIS A002997. The prime definition and list are from OEIS A000040; the bound that makes the 13-base Miller-Rabin test a proof is from OEIS A014233 (Sorenson and Webster). Computed in your browser; nothing is sent. Runs entirely in your browser. Nothing you type is sent or stored.
For learning
Primality results are exact below 10^24. This is a learning tool, not a cryptographic key checker.