Is it prime?
Type a whole number up to 400 digits to see if it's prime. Composite numbers come with their prime factors.
Input
Primality
—Type a whole number to check whether it's prime.
- Method
- Miller–Rabin
- Bonus
- Factorization
Related tools
This prime number checker tells you whether a whole number is prime, and for composite numbers it lists the prime factors, like 60 = 2 × 2 × 3 × 5. It runs the Miller–Rabin test on BigInt values, which stays fast all the way to the 400-digit limit. Below about 3.3 × 10^24 the answer is proven correct. Above that, a number that passes is labeled "prime (Miller–Rabin, 20 bases)", because there's a tiny chance it's a composite that slipped through. Everything runs in your browser.
How to check if a number is prime
- Type the number. Digits only; commas are ignored.
- The answer shows as you type: prime or not prime.
- For a composite, open Prime factorization to see the factors, such as 84 = 2 × 2 × 3 × 7. Click it to copy.
- Inputs over 400 digits are refused.
Why Miller–Rabin and not trial division
Trial division tries every possible divisor up to √n. That's fine for a 6-digit number and hopeless for a 30-digit one, where √n itself has 15 digits. Miller–Rabin runs a quick modular test against a handful of small prime bases instead. Using the first 13 primes as bases is proven to give the right answer for every n below 3,317,044,064,679,887,385,961,981; above that the tool uses 20 bases. Factoring still uses trial division, capped at divisors up to 1,000,000. If a large composite piece is left after that, it's shown as "(composite, not split)" rather than freezing the page.
Frequently asked questions
How do I know if a number is prime?
A prime has exactly two divisors, 1 and itself. 97 is prime. 91 isn't, because 91 = 7 × 13.
What is prime factorization?
Writing a composite number as a product of primes. Every whole number above 1 has exactly one such product, apart from the order. 84 = 2 × 2 × 3 × 7.
What is the largest number this tool can check?
400 digits. The primality test takes milliseconds even at that size. Factoring is the slow part, so for big numbers the tool may report a leftover composite factor it couldn't split.
Is 0 or 1 prime?
No. Primes start at 2, and 0 and 1 are neither prime nor composite. The tool reports both as not prime.
Built and maintained by Bipul Kumar. Found a wrong number or a broken result? Tell me and I'll fix it.