Prime Number Checker

Enter a whole number — find out instantly if it's prime, and see its prime factorization.

Type a whole number above — you'll instantly see if it's prime and its prime factorization.

How the prime checker and factorizer work

A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. Every other whole number above 1 is composite, meaning it can be built by multiplying smaller primes together. That single idea underlies cryptography, hashing, and much of number theory, which is why quickly deciding whether a number is prime — and, if not, what it factors into — is such a common task.

Testing small numbers is easy: to check whether n is prime you only need to try dividing by values up to the square root of n, because any factor larger than √n pairs with one smaller than it. For large numbers trial division becomes far too slow, so this tool switches to the Miller–Rabin primality test, which decides primality without finding factors. Below about 3.3 × 10²⁴ it uses a fixed set of witnesses and is deterministic; above that it becomes a strong probabilistic test and labels the answer a "probable prime."

Reading a factorization

Prime factorization rewrites a number as a product of primes, collapsing repeats into exponents. In 2³ × 3² × 5 the small raised digit is the exponent — how many times that prime is multiplied in. Once you have the factorization you can read off two useful quantities with no extra work:

Example 1 — 360. The factorization is 2³ × 3² × 5. The number of divisors is (3+1)(2+1)(1+1) = 24, and the sum of divisors is (1+2+4+8)(1+3+9)(1+5) = 15 × 13 × 6 = 1170.
Example 2 — 97. The square root of 97 is about 9.85, so it is enough to test the primes 2, 3, 5, and 7. None divides 97 evenly, so 97 is prime — no larger divisor needs checking.
Example 3 — 561. This looks prime to some quick tests but is not: 561 = 3 × 11 × 17. It is a Carmichael number, a composite that fools the simple Fermat test — exactly why the tool relies on the stronger Miller–Rabin test to catch it.

Edge cases the tool handles

InputResultWhy
0Not primeDivisible by every number; not greater than 1
1Not primeHas only one divisor, itself
2PrimeThe smallest prime and the only even one
−7RejectedPrimality is defined for positive integers

Practical notes and limits

Because the engine uses arbitrary-precision BigInt arithmetic, you are not restricted to ordinary integer sizes — you can paste numbers with dozens of digits. The limiting step is factorization, not the primality test: a large number that is the product of two big primes can be genuinely slow to factor, and if the search passes its time budget the tool tells you instead of freezing. Note too that "probable prime" for very large inputs means the chance of error is astronomically small but not mathematically zero. For everyday use — checking a number, teaching factorization, or verifying a result — the deterministic range covers far more than you are likely to need.

Sources & further reading

Frequently asked questions

How do I know if a number is prime?

A prime number is a whole number greater than 1 whose only divisors are 1 and itself — 7 is prime, but 9 = 3 × 3 is not. This prime number checker first tries dividing by small primes, then runs a Miller–Rabin primality test, so it decides in a split second even for large numbers. Just type a number and it tells you "Prime" or "Not prime" instantly.

What is prime factorization and how do I read exponent form?

Prime factorization breaks a number into the prime numbers that multiply to make it. This prime factorization calculator writes repeated factors as exponents: 360 = 2³ × 3² × 5 means 2 × 2 × 2 × 3 × 3 × 5. The small raised number (the exponent) is how many times that prime appears, so 2³ is "three twos multiplied together."

How large a number can it check?

The tool uses JavaScript BigInt, so it isn't limited to ordinary integers. Below roughly 3.3 × 10²⁴ the Miller–Rabin test is deterministic — the answer is exact. Above that it switches to a strong probabilistic test and labels the result "probable prime." Factorization of huge numbers with two large prime factors can be slow; if it hits the time limit it tells you rather than freezing.

Are 0 and 1 prime? Is 2 prime?

No — 0 and 1 are not prime, because a prime must be greater than 1 and have exactly two divisors. 1 has only one divisor (itself), and 0 is divisible by everything. 2 is the smallest prime and the only even prime; every other even number is divisible by 2. This checker handles all of these edge cases explicitly instead of erroring out.

Is my number sent to a server?

No. Every calculation — the primality test and the prime factorization — runs entirely in your browser with local JavaScript. Nothing you type is uploaded, logged or stored on a server, and there are no ads or sign-up. Your last input is saved only in your own browser (localStorage) so it's still there when you come back.