A prime number is a whole number greater than 1 whose only factors are 1 and itself: 2, 3, 5, 7, 11, 13 and so on. Every other whole number above 1 is composite and can be broken into smaller factors. This checker tells you which kind your number is, shows the trial divisions for numbers up to a trillion, finds the smallest factor of a composite, and lists the primes just before and after it.
How to use the prime number checker
- Enter a whole number, up to 30 digits. Commas are fine.
- The tape answers yes or no. For composites it shows the smallest prime factor and the full factorization; for primes it notes twin primes and, for numbers up to two million, where the prime falls in the sequence.
- The chips show the numbers around yours with the primes highlighted, so you can see how primes thin out and cluster.
How primality testing works
Trial division
If n has a factor, at least one factor is no bigger than √n. So you only need to test primes up to the square root:
Worked example: 221
Square root: √221 ≈ 14.87, so test 2, 3, 5, 7, 11 and 13
2: 221 is odd. 3: digit sum 5. 5: doesn't end in 0 or 5.
7: 221 ÷ 7 = 31.57… 11: 221 ÷ 11 = 20.09…
13: 221 ÷ 13 = 17 exactly
Conclusion: 221 = 13 × 17 is composite
Large numbers
Trial division for a 30-digit number would need around 10¹⁵ divisions. Instead, the calculator uses the Miller–Rabin test, based on Fermat’s little theorem: for a prime p, raising a base to a power related to p − 1 always gives a predictable remainder. Composites almost always fail for some base. With the first 13 prime bases, the test is mathematically guaranteed correct for every number below about 3.3 × 10²⁴; above that, 25 bases make an error vanishingly unlikely. When a number fails, Pollard’s rho algorithm hunts for a factor.
Facts about primes
- There are 25 primes below 100, 168 below 1,000 and 78,498 below one million. See the full list of prime numbers for any range.
- Twin primes differ by 2: (3, 5), (11, 13), (17, 19), (41, 43). Whether there are infinitely many is still an open question.
- There are infinitely many primes — a fact proved by Euclid around 300 BCE.
- Every prime greater than 3 is one more or one less than a multiple of 6, which is why primes above 3 are 6k ± 1.
- The largest known primes are Mersenne primes, of the form 2p − 1, with tens of millions of digits, found by distributed computing projects.
Quick tests before you calculate
| Divisor | Rule |
|---|---|
| 2 | The last digit is even |
| 3 | The digit sum is a multiple of 3 |
| 5 | The last digit is 0 or 5 |
| 7 | Double the last digit and subtract it from the rest; the result is a multiple of 7 |
| 11 | The alternating sum of digits is a multiple of 11 |
Why primes matter
Primes are the “atoms” of multiplication — every whole number factors into primes in exactly one way, which the prime factorization calculator shows. They also protect your data: RSA encryption relies on how easy it is to multiply two huge primes and how hard it is to factor the product back apart. Modular arithmetic, explored in the modulo calculator, is the language those algorithms are written in.
Frequently asked questions
How do I check if a number is prime?
Divide it by every prime up to its square root. If none divides evenly, the number is prime. For 97, the square root is about 9.85, and 2, 3, 5 and 7 all leave remainders, so 97 is prime.
Is 1 a prime number?
No. A prime must have exactly two different factors, 1 and itself. The number 1 has only one factor, so it is neither prime nor composite. Excluding it keeps every number's prime factorization unique.
Is 221 prime?
No. It looks prime because it isn't divisible by 2, 3, 5, 7 or 11, but 221 = 13 × 17. Numbers that are the product of two primes just above the easy tests are classic traps.
Why is 2 the only even prime?
Every other even number is divisible by 2, so it has at least three factors: 1, 2 and itself. That makes all even numbers greater than 2 composite.
How can the calculator check huge numbers so fast?
Trial division would take far too long for a 30-digit number, so it uses the Miller–Rabin test, which checks a mathematical property that every prime has. With the bases used here it is a proof of primality below about 3.3 × 10²⁴ and an extremely reliable test above that.