Prime Number Checker

Type any whole number to see whether it’s prime — and if not, exactly how it breaks down.

Try

Result

—

Enter a whole number.

  • Prime factorization—
  • Previous prime—
  • Next prime—

How to tell if a number is prime

A number n is prime if no whole number between 2 and √n divides it evenly. You only need to check up to the square root: if n = a × b and both factors were larger than √n, their product would be larger than n.

Quick divisibility checks by hand:

  • 2: the last digit is even.
  • 3: the sum of the digits is divisible by 3.
  • 5: the number ends in 0 or 5.
  • 11: the alternating sum of the digits (+ − + …) is divisible by 11.

How this checker works

For speed on very large numbers, the checker uses the Miller–Rabin primality test with a fixed set of bases that makes it exact for every number below 3.3 × 10²⁴. When a number is composite, Pollard’s rho algorithm finds its factors in milliseconds — even for 15-digit numbers like 600,851,475,143 = 71 × 839 × 1,471 × 6,857.

Prime numbers under 100

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, 97

Fun facts

  • There are infinitely many primes — Euclid proved it around 300 BC.
  • 561 = 3 × 11 × 17 is the smallest Carmichael number, which fools some simple primality tests.
  • 1,000,000,007 is prime and a favorite of programmers for keeping big calculations in range.

Need a random number to test? Use the random number generator.

Embed this calculator

Add the Prime Number Checker to your school, class or blog page — free, no account needed, and calculations run locally in the browser. Paste this code where you want it to appear:

Preview

The iframe resizes itself if your site allows scripts; otherwise it uses a fixed height of 540px. Please keep the credit line — it helps other teachers find the tool.

Frequently asked questions

What is a prime number?

A prime number is a whole number greater than 1 whose only divisors are 1 and itself. 2, 3, 5, 7, 11 and 13 are prime; 9 is not, because 3 × 3 = 9.

Is 1 a prime number?

No. By definition a prime must have exactly two distinct divisors. 1 has only one, so it is neither prime nor composite.

Is 2 the only even prime number?

Yes. Every other even number is divisible by 2, so it has at least three divisors (1, 2 and itself) and cannot be prime.

Is 39 a prime number?

No. 39 = 3 × 13, so it has divisors other than 1 and itself. A quick check: its digits add up to 12, which is divisible by 3, so 39 is too.

How big a number can I check?

Any whole number up to 10²⁴ (a 1 followed by 24 zeros). The checker uses a deterministic Miller–Rabin test, which is exact — not probabilistic — in this range, and Pollard’s rho algorithm for factorization.

What is prime factorization?

Every whole number above 1 can be written as a product of primes in exactly one way, such as 360 = 2³ × 3² × 5. This is called the fundamental theorem of arithmetic.

Sources

See how we build and test our tools in our editorial policy.