Prime Number Checker
Check if a number is prime (exact for below 3,317,044,064,679,887,385,961,981) and see its prime factorization, divisor count and the nearest primes either side.
Check whether a whole number is prime, meaning divisible only by 1 and itself, and if it is not, see its prime factors when they can be found within the calculation limit. The checker handles numbers below 3,317,044,064,679,887,385,961,981 with a deterministic Miller–Rabin test, so the yes-or-no answer is exact rather than a probability. It also gives the nearest primes below and above your number.
How to use this tool
- Type a whole number; commas and spaces are ignored.
- Read whether it is prime, composite, or neither (0 and 1).
- For a composite number, read its prime factorization, smallest prime factor and number of divisors.
- Use the previous and next prime to find the closest primes.
Formula
n is prime ⇔ n > 1 and no prime p ≤ √n divides n
Trial division up to √n is the textbook test. For large n the calculator uses the Miller–Rabin test with the 13 primes from 2 to 41 as bases, which is proven to give no false answers below 3.3 × 10²⁴. Composite numbers are then split with trial division and Pollard’s rho method. The divisor count comes from the factorization: if n = p₁^a × p₂^b × …, it has (a + 1)(b + 1)… divisors.
Example
91: √91 ≈ 9.5, so only 2, 3, 5 and 7 need testing. 91 ÷ 7 = 13, so 91 is composite: 91 = 7 × 13, with 4 divisors. 97: none of 2, 3, 5 or 7 divides it, so 97 is prime, and its neighbouring primes are 89 and 101. 360 = 2³ × 3² × 5, which has (3 + 1)(2 + 1)(1 + 1) = 24 divisors.
Frequently asked questions
Is 1 a prime number?
No. A prime must have exactly two distinct divisors, 1 and itself, and 1 has only one. Leaving 1 out also keeps every number’s prime factorization unique.
Is 2 the only even prime?
Yes. Every other even number is divisible by 2 as well as by 1 and itself, so it has at least three divisors.
How can I check a number by hand?
Divide by each prime up to its square root. Shortcuts help: a number is divisible by 3 if its digit sum is, by 5 if it ends in 0 or 5, and by 11 if its alternating digit sum is a multiple of 11.
Why is 561 a famous test case?
561 = 3 × 11 × 17 is the smallest Carmichael number: it passes the simple Fermat test for every base that shares no factor with it. Miller–Rabin catches it, which is why it is reported as composite here.
Last updated: 2026-10-30