Math & Scientific

Prime Number Checker

Check whether a number is prime, with its smallest factor and nearest primes if it isn't.

What makes a number prime

A prime number is a whole number greater than 1 that has exactly two divisors: 1 and itself. Numbers with more divisors (like 12, divisible by 1, 2, 3, 4, 6, and 12) are called composite.

This tool checks primality using trial division: it tests whether any number up to the square root of your input divides evenly into it. If none do, the number is prime — checking only up to the square root works because any factor larger than that would have to pair with a factor smaller than it.

Special cases

0 and 1 are neither prime nor composite — 1 has only one divisor, and 0 is divisible by every number, so neither fits the definition. 2 is the only even prime number, since every other even number is divisible by 2.

What the results show

  • A prime gets a line such as "97 is prime", followed by the next prime (101) and the previous prime (89).
  • A composite number also gets its smallest prime factor with the division written out: 91 gives 7 (91 ÷ 7 = 13), and 1,000,000 gives 2 (1,000,000 ÷ 2 = 500,000).
  • Only the smallest factor is shown, not a full factorization. 360 reports 2 (360 ÷ 2 = 180), and you would repeat the check on 180 to keep going.

Small and special inputs

2 is prime and has a next prime (3) but no previous prime, so that line is left out. 3 shows 5 and 2. For 1, 0 and negative numbers the tool says they are not prime and adds a "Why not" line with the reason, and still shows the next prime, which is 2. Decimals are refused with a message to remove the decimal, and an empty box asks you to enter a number.

The upper limit

Numbers up to 1,000,000,000,000,000 (10¹⁵) are accepted; anything larger is rejected. Near the top the next-prime line disappears: 999,999,999,999,989 is prime and shows only a previous prime (999,999,999,999,947).

Frequently asked questions

Why isn't 1 considered a prime number?

A prime number needs exactly two distinct divisors. 1 has only one divisor (itself), so it doesn't meet the definition — this is a deliberate convention, not an accident, and it keeps theorems like unique prime factorization consistent.

How large a number can this check?

Up to 1,000,000,000,000,000. Trial division gets slower as numbers grow, since it has to test divisors up to the square root of the input, so extremely large numbers are capped to keep the result instant.

What does 'smallest prime factor' mean?

It's the smallest prime number that divides your number evenly with no remainder. Every composite number has one, and dividing it out is the first step of finding a full prime factorization.

Does it give the full prime factorization?

No, only the smallest prime factor. For 360 it shows 2 (360 ÷ 2 = 180). To factor completely, check the quotient again, 180, then 90 and so on until you reach a prime.

Why does 1,000,000,000,000,000 show no next prime?

The next-prime search is skipped for numbers within 1,000 of the 10¹⁵ limit, so the search cannot run past what the tool can check reliably.

Related calculators