EthicalFusion

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

NumberResultNote
917 × 13looks prime, a classic exam trap
5613 × 187smallest Carmichael number
20262 × 1013even, so not prime
2027primethe next prime year
1,000,000,007primecommon 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.

Frequently asked questions

Is 1 a prime number?
No. A prime needs exactly two distinct factors, and 1 has only one.
Is 91 a prime number?
No. 91 equals 7 times 13. It is often mistaken for a prime because it is odd and not divisible by 3 or 5.
What is the only even prime number?
Two. Every other even number can be divided by 2, so it has more than two factors.
How large a number can this checker test?
Reliably up to 9,007,199,254,740,991. Larger integers cannot be stored exactly in the browser, so the result may be wrong.
Does it list all the factors of a number?
No. It shows the smallest factor it finds and the matching cofactor. Check the cofactor again to continue the factorisation.

Related tools

Embed this tool on your site

Paste it into any blog or website. Free, with a credit link.