Prime Number Checker
Check whether any number is prime.
Was this tool helpful?
Thanks for the feedback!
Type a whole number and this checker tells you whether it is prime. If it is not, it shows the smallest factor pair it found, for example 91 = 7 × 13, so you can see why.
How the check works: trial division up to the square root
A prime number has exactly two factors, 1 and itself. To test a number n, the checker tries dividing it by 2, 3, 4 and so on, but only up to √n. If n had a factor larger than its square root, it would have to pair with one smaller than the square root, which would already have been found.
For 97, √97 ≈ 9.85, so only 2 to 9 need testing. None of them divides 97 evenly, so it is prime. For 91, the search stops at 7 because 91 ÷ 7 = 13, and the result reads "91 is NOT prime" with "Divisible by 7 × 13".
Examples worth trying
| Number | Result | Note |
|---|---|---|
| 91 | 7 × 13 | looks prime, a classic exam trap |
| 561 | 3 × 187 | smallest Carmichael number |
| 2026 | 2 × 1013 | even, so not prime |
| 2027 | prime | the next prime year |
| 1,000,000,007 | prime | common modulus in coding contests |
561 is interesting because it passes Fermat's quick primality test for every base that shares no factor with it, even though it is composite. Trial division is not fooled by such numbers.
Rules and shortcuts to remember
- 1 is not prime. It has only one factor, and excluding it keeps every whole number's prime factorisation unique.
- 2 is the only even prime. Every other even number is divisible by 2.
- 0 and negative numbers are not prime; the checker reports them as not prime.
- Divisible by 3 if the digit sum is divisible by 3: 2,027 has digit sum 11, so 3 is not a factor.
- Divisible by 11 if the alternating digit sum (first − second + third …) is a multiple of 11.
- Every prime above 3 has the form 6k ± 1, but not every number of that form is prime: 25 = 6 × 4 + 1.
There are 25 primes below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97.
Limits
Decimals are rounded down before testing. The checker relies on standard JavaScript numbers, which are exact only up to 9,007,199,254,740,991; beyond that, the digits you type may be stored as a nearby even number and give a wrong answer. Numbers close to that limit may take a moment, since up to about 95 million divisions are needed. Cryptographic primes used in RSA run to hundreds of digits and need probabilistic tests such as Miller-Rabin, not trial division.
Only the first factor pair is shown. To break a composite number down fully, check the larger factor again, or use the LCM and HCF calculator to find factors two numbers share.